MT#65413 typed container for AVFrame

Change-Id: Ia319e54755ad9a0137206f63a1df9be5ad3a6e81
pull/2155/head
Richard Fuchs 7 days ago
parent c22d724aa9
commit d524f838d9

@ -301,7 +301,7 @@ static void amr_bitrate_tracker(decoder_t *dec, unsigned int ft) {
dec->avc.amr.bitrate_tracker[ft]++;
}
static int amr_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
static int amr_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
const char *err = NULL;
g_auto(GQueue) toc = G_QUEUE_INIT;
@ -619,7 +619,7 @@ static int packetizer_amr(AVPacket *pkt, GString *buf, str *output, size_t num_b
return 0;
}
static int amr_dtx(decoder_t *dec, GQueue *out, int ptime) {
static int amr_dtx(decoder_t *dec, frame_q *out, int ptime) {
// ignore ptime, must be 20
ilog(LOG_DEBUG, "pushing empty/lost frame to AMR decoder");
unsigned char frame_buf[1];

@ -73,7 +73,7 @@ void avc_decoder_close(decoder_t *dec) {
}
int avc_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
int avc_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
if (!dec->avc.avpkt)
return -1; // decoder shut down
@ -162,7 +162,7 @@ int avc_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
frame->pts = dec->avc.avpkt->pts;
dec->avc.avpkt->pts += frame->nb_samples;
g_queue_push_tail(out, frame);
t_queue_push_tail(out, frame);
frame = NULL;
}
} while (keep_going);

@ -20,11 +20,11 @@
static int generic_silence_dtx(decoder_t *, GQueue *, int);
static int generic_silence_dtx(decoder_t *, frame_q *, int);
static int generic_cn_dtx_init(decoder_t *);
static void generic_cn_dtx_cleanup(decoder_t *);
static int generic_cn_dtx(decoder_t *, GQueue *, int);
static int generic_cn_dtx(decoder_t *, frame_q *, int);
@ -231,7 +231,7 @@ void decoder_close(decoder_t *dec) {
static int __decoder_input_data(decoder_t *dec, const str *data, unsigned long ts, int *ptime,
int (*callback)(decoder_t *, AVFrame *, void *u1, void *u2), void *u1, void *u2)
{
GQueue frames = G_QUEUE_INIT;
frame_q frames = TYPED_GQUEUE_INIT;
if (G_UNLIKELY(!dec))
return -1;
@ -270,7 +270,7 @@ static int __decoder_input_data(decoder_t *dec, const str *data, unsigned long t
AVFrame *frame;
int ret = 0;
unsigned long samples = 0;
while ((frame = g_queue_pop_head(&frames))) {
while ((frame = t_queue_pop_head(&frames))) {
samples += frame->nb_samples;
dec->dec_out_format.format = frame->format;
AVFrame *rsmp_frame = resample_frame(&dec->resampler, frame, &dec->dest_format);
@ -911,7 +911,7 @@ void codeclib_key_value_parse(const str *instr, bool need_value,
static int generic_silence_dtx(decoder_t *dec, GQueue *out, int ptime) {
static int generic_silence_dtx(decoder_t *dec, frame_q *out, int ptime) {
if (dec->dec_out_format.format == -1)
return -1;
if (!dec->avc.avpkt)
@ -939,7 +939,7 @@ static int generic_silence_dtx(decoder_t *dec, GQueue *out, int ptime) {
frame->pts = dec->avc.avpkt->pts;
dec->avc.avpkt->pts += frame->nb_samples;
g_queue_push_tail(out, frame);
t_queue_push_tail(out, frame);
return 0;
}
@ -951,7 +951,7 @@ static int cn_append_frame(decoder_t *dec, AVFrame *f, void *u1, void *u2) {
return 0;
}
static int generic_cn_dtx(decoder_t *dec, GQueue *out, int ptime) {
static int generic_cn_dtx(decoder_t *dec, frame_q *out, int ptime) {
dec->dtx.cn.cn_dec->ptime = ptime;
return decoder_input_data(dec->dtx.cn.cn_dec, dec->dtx.cn.cn_payload,
dec->rtp_ts, cn_append_frame, out, NULL);

@ -116,12 +116,14 @@ typedef bool format_parse_f(struct rtp_codec_format *, const str *fmtp);
typedef void format_answer_f(struct rtp_payload_type *, const struct rtp_payload_type *);
TYPED_GQUEUE(frame, AVFrame);
struct codec_type_s {
void (*def_init)(struct codec_def_s *);
const char *(*decoder_init)(decoder_t *, const str *);
int (*decoder_input)(decoder_t *, const str *data, GQueue *);
int (*decoder_input)(decoder_t *, const str *data, frame_q *);
void (*decoder_close)(decoder_t *);
const char *(*encoder_init)(encoder_t *, const str *);
@ -264,7 +266,7 @@ struct dtx_method_s {
int (*init)(decoder_t *);
void (*cleanup)(decoder_t *);
int (*do_dtx)(decoder_t *, GQueue *, int);
int (*do_dtx)(decoder_t *, frame_q *, int);
union {
struct {

@ -20,7 +20,7 @@ void avc_cleanup(void);
void avc_def_init(struct codec_def_s *);
const char *avc_decoder_init(decoder_t *, const str *);
int avc_decoder_input(decoder_t *dec, const str *data, GQueue *out);
int avc_decoder_input(decoder_t *dec, const str *data, frame_q *out);
void avc_decoder_close(decoder_t *);
const char *avc_encoder_init(encoder_t *enc, const str *);
int avc_encoder_input(encoder_t *enc, AVFrame **frame);

@ -145,7 +145,7 @@ static void float2int16_array(float *in, const uint16_t len, int16_t *out)
static void evs_push_frame(decoder_t *dec, char *frame_data, int bits, int is_amr, int mode, int q_bit,
GQueue *out)
frame_q *out)
{
const unsigned int n_samples = 960; // fixed 20 ms ptime
uint64_t pts = dec->pts;
@ -183,7 +183,7 @@ static void evs_push_frame(decoder_t *dec, char *frame_data, int bits, int is_am
pts += n_samples;
dec->pts = pts;
g_queue_push_tail(out, frame);
t_queue_push_tail(out, frame);
}
@ -291,7 +291,7 @@ static const int evs_mode_bits[2][16] = {
};
static int evs_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
static int evs_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
str input = *data;
const char *err = NULL;
@ -413,7 +413,7 @@ err:
}
static int evs_dtx(decoder_t *dec, GQueue *out, int ptime) {
static int evs_dtx(decoder_t *dec, frame_q *out, int ptime) {
ilog(LOG_DEBUG, "pushing empty/lost frame to EVS decoder");
evs_push_frame(dec, NULL, 0, 0, 0, 0, out);
return 0;

@ -48,7 +48,7 @@ static packetizer_f packetizer_g729; // aggregate some frames into packets
static void bcg729_def_init(struct codec_def_s *);
static const char *bcg729_decoder_init(decoder_t *, const str *);
static int bcg729_decoder_input(decoder_t *dec, const str *data, GQueue *out);
static int bcg729_decoder_input(decoder_t *dec, const str *data, frame_q *out);
static void bcg729_decoder_close(decoder_t *);
static const char *bcg729_encoder_init(encoder_t *enc, const str *);
static int bcg729_encoder_input(encoder_t *enc, AVFrame **frame);
@ -127,7 +127,7 @@ static const char *bcg729_decoder_init(decoder_t *dec, const str *extra_opts) {
return NULL;
}
static int bcg729_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
static int bcg729_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
str input = *data;
uint64_t pts = dec->pts;
@ -152,7 +152,7 @@ static int bcg729_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
bcg729Decoder(dec->bcg729, (void *) inp_frame.s, inp_frame.len, 0, 0, 0,
(void *) frame->extended_data[0]);
g_queue_push_tail(out, frame);
t_queue_push_tail(out, frame);
}
return 0;

@ -67,7 +67,7 @@ static void ilbc_set_dec_options(decoder_t *dec, const str *codec_opts) {
ilog(LOG_WARN, "Unsupported iLBC mode %i", mode);
}
static int ilbc_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
static int ilbc_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
int mode = 0, block_align = 0;
static const union codec_format_options mode_20 = { .ilbc = { 20 } };
static const union codec_format_options mode_30 = { .ilbc = { 30 } };

@ -80,7 +80,7 @@ static const char *libopus_decoder_init(decoder_t *dec, const str *extra_opts) {
static void libopus_decoder_close(decoder_t *dec) {
opus_decoder_destroy(dec->opus);
}
static int libopus_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
static int libopus_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
// get frame with buffer large enough for the max
AVFrame *frame = av_frame_alloc();
frame->nb_samples = 960;
@ -100,7 +100,7 @@ static int libopus_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
}
frame->nb_samples = ret;
g_queue_push_tail(out, frame);
t_queue_push_tail(out, frame);
return 0;
}

@ -34,7 +34,7 @@ static AVFrame *dtmf_frame_int16_t_mono(unsigned long frame_ts, unsigned long nu
}
static int dtmf_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
static int dtmf_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
struct telephone_event_payload *dtmf;
if (data->len < sizeof(*dtmf)) {
ilog(LOG_WARN | LOG_FLAG_LIMIT, "Short DTMF event packet (len %zu)", data->len);
@ -71,7 +71,7 @@ static int dtmf_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
AVFrame *frame = dtmf_frame_int16_t_mono(frame_ts, num_samples, dtmf->event, dtmf->volume,
dec->in_format.clockrate);
frame->pts += dec->dtmf.start_ts;
g_queue_push_tail(out, frame);
t_queue_push_tail(out, frame);
dec->dtmf.duration = duration;
@ -87,7 +87,7 @@ static const char *cn_decoder_init(decoder_t *dec, const str *opts) {
dec->resampler.no_filter = true;
return avc_decoder_init(dec, opts);
}
static int cn_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
static int cn_decoder_input(decoder_t *dec, const str *data, frame_q *out) {
// generate one set of ptime worth of samples
int ptime = dec->ptime;
if (ptime <= 0)
@ -137,7 +137,7 @@ static int cn_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
}
while (out->length) {
oframe = g_queue_pop_head(out);
oframe = t_queue_pop_head(out);
if (oframe->nb_samples <= 0) // error
return -1; // XXX leaves frames in `out`
@ -155,7 +155,7 @@ static int cn_decoder_input(decoder_t *dec, const str *data, GQueue *out) {
};
} while (samples > 0);
g_queue_push_tail(out, aframe);
t_queue_push_tail(out, aframe);
return 0;
}

Loading…
Cancel
Save