static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { AVFrame *frame = data; int ret = 0; if ((ret = ffmmal_add_packet(avctx, avpkt)) < 0) return ret; if ((ret = ffmmal_fill_input_port(avctx)) < 0) return ret; if ((ret = ffmmal_fill_output_port(avctx)) < 0) return ret; if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0) return ret; // ffmmal_read_frame() can block for a while. Since the decoder is // asynchronous, it's a good idea to fill the ports again. if ((ret = ffmmal_fill_output_port(avctx)) < 0) return ret; if ((ret = ffmmal_fill_input_port(avctx)) < 0) return ret; return ret; }
static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { MMALDecodeContext *ctx = avctx->priv_data; AVFrame *frame = data; int ret = 0; if (avctx->extradata_size && !ctx->extradata_sent) { AVPacket pkt = {0}; av_init_packet(&pkt); pkt.data = avctx->extradata; pkt.size = avctx->extradata_size; ctx->extradata_sent = 1; if ((ret = ffmmal_add_packet(avctx, &pkt, 1)) < 0) return ret; } if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0) return ret; if ((ret = ffmmal_fill_input_port(avctx)) < 0) return ret; if ((ret = ffmmal_fill_output_port(avctx)) < 0) return ret; if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0) return ret; // ffmmal_read_frame() can block for a while. Since the decoder is // asynchronous, it's a good idea to fill the ports again. if ((ret = ffmmal_fill_output_port(avctx)) < 0) return ret; if ((ret = ffmmal_fill_input_port(avctx)) < 0) return ret; return ret; }