From a553c6a347d3d28d7ee44c3df3d5c4ee780dba23 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 1 Nov 2013 18:07:22 +0100 Subject: lavc: use buf[0] instead of data[0] in checks whether a frame is allocated data[0] may be NULL for valid frames with hwaccel pixel formats. --- libavcodec/mpegvideo.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'libavcodec/mpegvideo.c') diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 48a7320a24..7ffb2615df 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -236,7 +236,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) r = avcodec_default_get_buffer2(s->avctx, &pic->f, 0); } - if (r < 0 || !pic->f.data[0]) { + if (r < 0 || !pic->f.buf[0]) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n", r, pic->f.data[0]); return -1; @@ -372,7 +372,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) assert(pic->f.data[0]); pic->shared = 1; } else { - assert(!pic->f.data[0]); + assert(!pic->f.buf[0]); if (alloc_frame_buffer(s, pic) < 0) return -1; @@ -674,7 +674,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, for (i = 0; i < MAX_PICTURE_COUNT; i++) { ff_mpeg_unref_picture(s, &s->picture[i]); - if (s1->picture[i].f.data[0] && + if (s1->picture[i].f.buf[0] && (ret = ff_mpeg_ref_picture(s, &s->picture[i], &s1->picture[i])) < 0) return ret; } @@ -682,7 +682,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, #define UPDATE_PICTURE(pic)\ do {\ ff_mpeg_unref_picture(s, &s->pic);\ - if (s1->pic.f.data[0])\ + if (s1->pic.f.buf[0])\ ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\ else\ ret = update_picture_tables(&s->pic, &s1->pic);\ @@ -1401,7 +1401,7 @@ void ff_release_unused_pictures(MpegEncContext*s, int remove_current) static inline int pic_is_unused(MpegEncContext *s, Picture *pic) { - if (pic->f.data[0] == NULL) + if (pic->f.buf[0] == NULL) return 1; if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF)) return 1; @@ -1414,7 +1414,7 @@ static int find_unused_picture(MpegEncContext *s, int shared) if (shared) { for (i = 0; i < MAX_PICTURE_COUNT; i++) { - if (s->picture[i].f.data[0] == NULL) + if (s->picture[i].f.buf[0] == NULL) return i; } } else { @@ -1476,7 +1476,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* mark & release old frames */ if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && - s->last_picture_ptr->f.data[0]) { + s->last_picture_ptr->f.buf[0]) { ff_mpeg_unref_picture(s, s->last_picture_ptr); } @@ -1501,7 +1501,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ff_release_unused_pictures(s, 1); if (s->current_picture_ptr && - s->current_picture_ptr->f.data[0] == NULL) { + s->current_picture_ptr->f.buf[0] == NULL) { // we already have a unused image // (maybe it was set before reading the header) pic = s->current_picture_ptr; @@ -1561,7 +1561,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) s->pict_type, s->droppable); if ((s->last_picture_ptr == NULL || - s->last_picture_ptr->f.data[0] == NULL) && + s->last_picture_ptr->f.buf[0] == NULL) && (s->pict_type != AV_PICTURE_TYPE_I || s->picture_structure != PICT_FRAME)) { int h_chroma_shift, v_chroma_shift; @@ -1599,7 +1599,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1); } if ((s->next_picture_ptr == NULL || - s->next_picture_ptr->f.data[0] == NULL) && + s->next_picture_ptr->f.buf[0] == NULL) && s->pict_type == AV_PICTURE_TYPE_B) { /* Allocate a dummy frame */ i = ff_find_unused_picture(s, 0); @@ -1618,21 +1618,21 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) if (s->last_picture_ptr) { ff_mpeg_unref_picture(s, &s->last_picture); - if (s->last_picture_ptr->f.data[0] && + if (s->last_picture_ptr->f.buf[0] && (ret = ff_mpeg_ref_picture(s, &s->last_picture, s->last_picture_ptr)) < 0) return ret; } if (s->next_picture_ptr) { ff_mpeg_unref_picture(s, &s->next_picture); - if (s->next_picture_ptr->f.data[0] && + if (s->next_picture_ptr->f.buf[0] && (ret = ff_mpeg_ref_picture(s, &s->next_picture, s->next_picture_ptr)) < 0) return ret; } if (s->pict_type != AV_PICTURE_TYPE_I && - !(s->last_picture_ptr && s->last_picture_ptr->f.data[0])) { + !(s->last_picture_ptr && s->last_picture_ptr->f.buf[0])) { av_log(s, AV_LOG_ERROR, "Non-reference picture received and no reference available\n"); return AVERROR_INVALIDDATA; -- cgit v1.2.3