From 4012cd6c4f19f09cac86c9b8c9738f27bb691764 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 5 Dec 2012 18:24:43 +0000 Subject: [PATCH] lavc: fix decode_frame() third parameter semantics for rest of video decoders Signed-off-by: Paul B Mahol --- libavcodec/avrndec.c | 7 ++++--- libavcodec/avuidec.c | 4 ++-- libavcodec/bintext.c | 4 ++-- libavcodec/brender_pix.c | 4 ++-- libavcodec/cpia.c | 6 +++--- libavcodec/crystalhd.c | 22 +++++++++++----------- libavcodec/diracdec.c | 16 ++++++++-------- libavcodec/escape130.c | 6 +++--- libavcodec/exr.c | 4 ++-- libavcodec/j2kdec.c | 4 ++-- libavcodec/libstagefright.cpp | 4 ++-- libavcodec/libutvideodec.cpp | 4 ++-- libavcodec/paf.c | 4 ++-- libavcodec/proresdec2.c | 4 ++-- libavcodec/targa_y216dec.c | 4 ++-- libavcodec/v308dec.c | 4 ++-- libavcodec/v408dec.c | 4 ++-- libavcodec/vda_h264_dec.c | 6 +++--- libavcodec/xbmdec.c | 4 ++-- libavcodec/xfacedec.c | 4 ++-- libavcodec/y41pdec.c | 4 ++-- libavcodec/yuv4dec.c | 4 ++-- 22 files changed, 64 insertions(+), 63 deletions(-) diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index 187dad5398..0fc431d4da 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -80,7 +80,8 @@ static av_cold int end(AVCodecContext *avctx) return 0; } -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) +static int decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) { AVRnContext *a = avctx->priv_data; AVFrame *p = &a->frame; @@ -89,7 +90,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac int y, ret, true_height; if(a->is_mjpeg) - return ff_mjpeg_decode_frame(avctx, data, data_size, avpkt); + return ff_mjpeg_decode_frame(avctx, data, got_frame, avpkt); true_height = buf_size / (2*avctx->width); if(p->data[0]) @@ -123,7 +124,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac } *(AVFrame*)data = a->frame; - *data_size = sizeof(AVFrame); + *got_frame = 1; return buf_size; } diff --git a/libavcodec/avuidec.c b/libavcodec/avuidec.c index 7aa30ff8ff..22af719090 100644 --- a/libavcodec/avuidec.c +++ b/libavcodec/avuidec.c @@ -39,7 +39,7 @@ static av_cold int avui_decode_init(AVCodecContext *avctx) } static int avui_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { AVFrame *pic = avctx->coded_frame; const uint8_t *src = avpkt->data, *extradata = avctx->extradata; @@ -128,7 +128,7 @@ static int avui_decode_frame(AVCodecContext *avctx, void *data, src += 4; srca += 4; } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *pic; return avpkt->size; diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c index 9c36b6ba01..1c9bc3e6a1 100644 --- a/libavcodec/bintext.c +++ b/libavcodec/bintext.c @@ -129,7 +129,7 @@ static void draw_char(AVCodecContext *avctx, int c, int a) } static int decode_frame(AVCodecContext *avctx, - void *data, int *data_size, + void *data, int *got_frame, AVPacket *avpkt) { XbinContext *s = avctx->priv_data; @@ -201,7 +201,7 @@ static int decode_frame(AVCodecContext *avctx, } } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame*)data = s->frame; return buf_size; } diff --git a/libavcodec/brender_pix.c b/libavcodec/brender_pix.c index 92bc8b4e1b..5245fa0d71 100644 --- a/libavcodec/brender_pix.c +++ b/libavcodec/brender_pix.c @@ -70,7 +70,7 @@ static int brpix_decode_header(BRPixHeader *out, GetByteContext *pgb) } static int brpix_decode_frame(AVCodecContext *avctx, - void *data, int *data_size_out, + void *data, int *got_frame, AVPacket *avpkt) { BRPixContext *s = avctx->priv_data; @@ -217,7 +217,7 @@ static int brpix_decode_frame(AVCodecContext *avctx, } *frame_out = s->frame; - *data_size_out = sizeof(AVFrame); + *got_frame = 1; return avpkt->size; } diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c index 26e067a5cc..f741eb9e5e 100644 --- a/libavcodec/cpia.c +++ b/libavcodec/cpia.c @@ -46,8 +46,8 @@ typedef struct { } CpiaContext; -static int cpia_decode_frame(AVCodecContext* avctx, - void* data, int* data_size, AVPacket* avpkt) +static int cpia_decode_frame(AVCodecContext *avctx, + void *data, int *got_frame, AVPacket* avpkt) { CpiaContext* const cpia = avctx->priv_data; int i,j,ret; @@ -183,7 +183,7 @@ static int cpia_decode_frame(AVCodecContext* avctx, } } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame*) data = *frame; return avpkt->size; diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index d18243c128..95f1fb6e8d 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -536,7 +536,7 @@ static av_cold int init(AVCodecContext *avctx) static inline CopyRet copy_frame(AVCodecContext *avctx, BC_DTS_PROC_OUT *output, - void *data, int *data_size) + void *data, int *got_frame) { BC_STATUS ret; BC_DTS_STATUS decoder_status = { 0, }; @@ -696,7 +696,7 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, priv->pic.pkt_pts = pkt_pts; if (!priv->need_second_field) { - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = priv->pic; } @@ -733,7 +733,7 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, static inline CopyRet receive_frame(AVCodecContext *avctx, - void *data, int *data_size) + void *data, int *got_frame) { BC_STATUS ret; BC_DTS_PROC_OUT output = { @@ -743,7 +743,7 @@ static inline CopyRet receive_frame(AVCodecContext *avctx, CHDContext *priv = avctx->priv_data; HANDLE dev = priv->dev; - *data_size = 0; + *got_frame = 0; // Request decoded data from the driver ret = DtsProcOutputNoCopy(dev, OUTPUT_PROC_TIMEOUT, &output); @@ -840,8 +840,8 @@ static inline CopyRet receive_frame(AVCodecContext *avctx, priv->last_picture = output.PicInfo.picture_number - 1; } - copy_ret = copy_frame(avctx, &output, data, data_size); - if (*data_size > 0) { + copy_ret = copy_frame(avctx, &output, data, got_frame); + if (*got_frame > 0) { avctx->has_b_frames--; priv->last_picture++; av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Pipeline length: %u\n", @@ -868,7 +868,7 @@ static inline CopyRet receive_frame(AVCodecContext *avctx, } -static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) +static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { BC_STATUS ret; BC_DTS_STATUS decoder_status = { 0, }; @@ -1026,8 +1026,8 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a } do { - rec_ret = receive_frame(avctx, data, data_size); - if (rec_ret == RET_OK && *data_size == 0) { + rec_ret = receive_frame(avctx, data, got_frame); + if (rec_ret == RET_OK && *got_frame == 0) { /* * This case is for when the encoded fields are stored * separately and we get a separate avpkt for each one. To keep @@ -1052,8 +1052,8 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a ret = DtsGetDriverStatus(dev, &decoder_status); if (ret == BC_STS_SUCCESS && decoder_status.ReadyListCount > 0) { - rec_ret = receive_frame(avctx, data, data_size); - if ((rec_ret == RET_OK && *data_size > 0) || + rec_ret = receive_frame(avctx, data, got_frame); + if ((rec_ret == RET_OK && *got_frame > 0) || rec_ret == RET_ERROR) break; } diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index 571989aa64..8e62391555 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -1706,7 +1706,7 @@ static int dirac_decode_picture_header(DiracContext *s) return 0; } -static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *data_size) +static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame) { DiracFrame *out = s->delay_frames[0]; int i, out_idx = 0; @@ -1723,7 +1723,7 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *data_size) if (out) { out->avframe.reference ^= DELAYED_PIC_REF; - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)picture = out->avframe; } @@ -1827,7 +1827,7 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int return 0; } -static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) +static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt) { DiracContext *s = avctx->priv_data; DiracFrame *picture = data; @@ -1843,11 +1843,11 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } s->current_picture = NULL; - *data_size = 0; + *got_frame = 0; /* end of stream, so flush delayed pics */ if (buf_size == 0) - return get_delayed_pic(s, (AVFrame *)data, data_size); + return get_delayed_pic(s, (AVFrame *)data, got_frame); for (;;) { /*[DIRAC_STD] Here starts the code from parse_info() defined in 9.6 @@ -1905,15 +1905,15 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, if (delayed_frame) { delayed_frame->avframe.reference ^= DELAYED_PIC_REF; *(AVFrame*)data = delayed_frame->avframe; - *data_size = sizeof(AVFrame); + *got_frame = 1; } } else if (s->current_picture->avframe.display_picture_number == s->frame_number) { /* The right frame at the right time :-) */ *(AVFrame*)data = s->current_picture->avframe; - *data_size = sizeof(AVFrame); + *got_frame = 1; } - if (*data_size) + if (*got_frame) s->frame_number = picture->avframe.display_picture_number + 1; return buf_idx; diff --git a/libavcodec/escape130.c b/libavcodec/escape130.c index b56bb4463d..ca6a2531ce 100644 --- a/libavcodec/escape130.c +++ b/libavcodec/escape130.c @@ -93,13 +93,13 @@ static unsigned decode_skip_count(GetBitContext* gb) { * Decode a single frame * @param avctx decoder context * @param data decoded frame - * @param data_size size of the decoded frame + * @param got_frame have decoded frame * @param buf input buffer * @param buf_size input buffer size * @return 0 success, -1 on error */ static int escape130_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, + void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; @@ -302,7 +302,7 @@ static int escape130_decode_frame(AVCodecContext *avctx, avctx->release_buffer(avctx, &s->frame); *(AVFrame*)data = s->frame = new_frame; - *data_size = sizeof(AVFrame); + *got_frame = 1; return buf_size; } diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 6773d88515..fef0d105e0 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -223,7 +223,7 @@ static int rle_uncompress(const uint8_t *src, int ssize, uint8_t *dst, int dsize static int decode_frame(AVCodecContext *avctx, void *data, - int *data_size, + int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; @@ -633,7 +633,7 @@ static int decode_frame(AVCodecContext *avctx, } *picture = s->picture; - *data_size = sizeof(AVPicture); + *got_frame = 1; return buf_size; } diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c index a9b4ccf3d6..53c4f079f8 100644 --- a/libavcodec/j2kdec.c +++ b/libavcodec/j2kdec.c @@ -1018,7 +1018,7 @@ static int jp2_find_codestream(J2kDecoderContext *s) } static int decode_frame(AVCodecContext *avctx, - void *data, int *data_size, + void *data, int *got_frame, AVPacket *avpkt) { J2kDecoderContext *s = avctx->priv_data; @@ -1061,7 +1061,7 @@ static int decode_frame(AVCodecContext *avctx, cleanup(s); - *data_size = sizeof(AVPicture); + *got_frame = 1; *picture = s->picture; return bytestream2_tell(&s->g); diff --git a/libavcodec/libstagefright.cpp b/libavcodec/libstagefright.cpp index f65b489bf5..4c270b0342 100644 --- a/libavcodec/libstagefright.cpp +++ b/libavcodec/libstagefright.cpp @@ -354,7 +354,7 @@ fail: } static int Stagefright_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { StagefrightContext *s = (StagefrightContext*)avctx->priv_data; Frame *frame; @@ -463,7 +463,7 @@ static int Stagefright_decode_frame(AVCodecContext *avctx, void *data, } s->prev_frame = ret_frame; - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame*)data = *ret_frame; return orig_size; } diff --git a/libavcodec/libutvideodec.cpp b/libavcodec/libutvideodec.cpp index f4ba8b3bda..f70ac4f48f 100644 --- a/libavcodec/libutvideodec.cpp +++ b/libavcodec/libutvideodec.cpp @@ -115,7 +115,7 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx) } static int utvideo_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; AVFrame *pic = avctx->coded_frame; @@ -150,7 +150,7 @@ static int utvideo_decode_frame(AVCodecContext *avctx, void *data, break; } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *pic; return avpkt->size; diff --git a/libavcodec/paf.c b/libavcodec/paf.c index 39d6509542..adb37ee7b6 100644 --- a/libavcodec/paf.c +++ b/libavcodec/paf.c @@ -245,7 +245,7 @@ static int decode_0(AVCodecContext *avctx, uint8_t code, uint8_t *pkt) } static int paf_vid_decode(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *pkt) + int *got_frame, AVPacket *pkt) { PAFVideoDecContext *c = avctx->priv_data; uint8_t code, *dst, *src, *end; @@ -357,7 +357,7 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data, c->current_frame = (c->current_frame + 1) & 3; - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = c->pic; return pkt->size; diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index 7064fb48d8..3b3175a41a 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -522,7 +522,7 @@ static int decode_picture(AVCodecContext *avctx) return 0; } -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, +static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { ProresContext *ctx = avctx->priv_data; @@ -574,7 +574,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, goto decode_picture; } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame*)data = *frame; return avpkt->size; diff --git a/libavcodec/targa_y216dec.c b/libavcodec/targa_y216dec.c index 0e999dbcfa..3b97000c53 100644 --- a/libavcodec/targa_y216dec.c +++ b/libavcodec/targa_y216dec.c @@ -38,7 +38,7 @@ static av_cold int y216_decode_init(AVCodecContext *avctx) } static int y216_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { AVFrame *pic = avctx->coded_frame; const uint16_t *src = (uint16_t *)avpkt->data; @@ -81,7 +81,7 @@ static int y216_decode_frame(AVCodecContext *avctx, void *data, src += aligned_width << 1; } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *pic; return avpkt->size; diff --git a/libavcodec/v308dec.c b/libavcodec/v308dec.c index e8eaeb4e19..b5567f8574 100644 --- a/libavcodec/v308dec.c +++ b/libavcodec/v308dec.c @@ -40,7 +40,7 @@ static av_cold int v308_decode_init(AVCodecContext *avctx) } static int v308_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { AVFrame *pic = avctx->coded_frame; const uint8_t *src = avpkt->data; @@ -81,7 +81,7 @@ static int v308_decode_frame(AVCodecContext *avctx, void *data, v += pic->linesize[2]; } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *pic; return avpkt->size; diff --git a/libavcodec/v408dec.c b/libavcodec/v408dec.c index 37f1d6ee87..470853d551 100644 --- a/libavcodec/v408dec.c +++ b/libavcodec/v408dec.c @@ -37,7 +37,7 @@ static av_cold int v408_decode_init(AVCodecContext *avctx) } static int v408_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { AVFrame *pic = avctx->coded_frame; const uint8_t *src = avpkt->data; @@ -88,7 +88,7 @@ static int v408_decode_frame(AVCodecContext *avctx, void *data, a += pic->linesize[3]; } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *pic; return avpkt->size; diff --git a/libavcodec/vda_h264_dec.c b/libavcodec/vda_h264_dec.c index 3cb13e38fb..d6c8f379bd 100644 --- a/libavcodec/vda_h264_dec.c +++ b/libavcodec/vda_h264_dec.c @@ -84,14 +84,14 @@ static void release_buffer(AVCodecContext *avctx, AVFrame *pic) } static int vdadec_decode(AVCodecContext *avctx, - void *data, int *data_size, AVPacket *avpkt) + void *data, int *got_frame, AVPacket *avpkt) { VDADecoderContext *ctx = avctx->priv_data; AVFrame *pic = data; int ret; - ret = ff_h264_decoder.decode(avctx, data, data_size, avpkt); - if (*data_size) { + ret = ff_h264_decoder.decode(avctx, data, got_frame, avpkt); + if (*got_frame) { CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->data[3]; CVPixelBufferLockBaseAddress(cv_buffer, 0); pic->format = ctx->pix_fmt; diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index 39ed50392f..2a41836492 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -45,7 +45,7 @@ static int convert(uint8_t x) } static int xbm_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { AVFrame *p = avctx->coded_frame; const uint8_t *end, *ptr = avpkt->data; @@ -110,7 +110,7 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data, p->key_frame = 1; p->pict_type = AV_PICTURE_TYPE_I; - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *p; return avpkt->size; diff --git a/libavcodec/xfacedec.c b/libavcodec/xfacedec.c index cc7f7b22f0..a2f8636cae 100644 --- a/libavcodec/xfacedec.c +++ b/libavcodec/xfacedec.c @@ -124,7 +124,7 @@ static av_cold int xface_decode_close(AVCodecContext *avctx) } static int xface_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, + void *data, int *got_frame, AVPacket *avpkt) { XFaceContext *xface = avctx->priv_data; @@ -189,7 +189,7 @@ static int xface_decode_frame(AVCodecContext *avctx, } } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame*)data = xface->frame; return avpkt->size; diff --git a/libavcodec/y41pdec.c b/libavcodec/y41pdec.c index 45c994d98a..655a426143 100644 --- a/libavcodec/y41pdec.c +++ b/libavcodec/y41pdec.c @@ -42,7 +42,7 @@ static av_cold int y41p_decode_init(AVCodecContext *avctx) } static int y41p_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { AVFrame *pic = avctx->coded_frame; uint8_t *src = avpkt->data; @@ -89,7 +89,7 @@ static int y41p_decode_frame(AVCodecContext *avctx, void *data, } } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *pic; return avpkt->size; diff --git a/libavcodec/yuv4dec.c b/libavcodec/yuv4dec.c index 6454fbfff8..8eb72c2a5e 100644 --- a/libavcodec/yuv4dec.c +++ b/libavcodec/yuv4dec.c @@ -38,7 +38,7 @@ static av_cold int yuv4_decode_init(AVCodecContext *avctx) } static int yuv4_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) + int *got_frame, AVPacket *avpkt) { AVFrame *pic = avctx->coded_frame; const uint8_t *src = avpkt->data; @@ -82,7 +82,7 @@ static int yuv4_decode_frame(AVCodecContext *avctx, void *data, v += pic->linesize[2]; } - *data_size = sizeof(AVFrame); + *got_frame = 1; *(AVFrame *)data = *pic; return avpkt->size;