Commit 56e12278 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'a553c6a3'

* commit 'a553c6a3':
  lavc: use buf[0] instead of data[0] in checks whether a frame is allocated

Conflicts:
	libavcodec/h264_refs.c
	libavcodec/mpegvideo.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents f0f04fd8 a553c6a3
...@@ -281,7 +281,7 @@ static void unref_picture(H264Context *h, Picture *pic) ...@@ -281,7 +281,7 @@ static void unref_picture(H264Context *h, Picture *pic)
int off = offsetof(Picture, tf) + sizeof(pic->tf); int off = offsetof(Picture, tf) + sizeof(pic->tf);
int i; int i;
if (!pic->f.data[0]) if (!pic->f.buf[0])
return; return;
ff_thread_release_buffer(h->avctx, &pic->tf); ff_thread_release_buffer(h->avctx, &pic->tf);
...@@ -303,7 +303,7 @@ static void release_unused_pictures(H264Context *h, int remove_current) ...@@ -303,7 +303,7 @@ static void release_unused_pictures(H264Context *h, int remove_current)
/* release non reference frames */ /* release non reference frames */
for (i = 0; i < MAX_PICTURE_COUNT; i++) { for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (h->DPB[i].f.data[0] && !h->DPB[i].reference && if (h->DPB[i].f.buf[0] && !h->DPB[i].reference &&
(remove_current || &h->DPB[i] != h->cur_pic_ptr)) { (remove_current || &h->DPB[i] != h->cur_pic_ptr)) {
unref_picture(h, &h->DPB[i]); unref_picture(h, &h->DPB[i]);
} }
...@@ -485,7 +485,7 @@ fail: ...@@ -485,7 +485,7 @@ fail:
static inline int pic_is_unused(H264Context *h, Picture *pic) static inline int pic_is_unused(H264Context *h, Picture *pic)
{ {
if (pic->f.data[0] == NULL) if (!pic->f.buf[0])
return 1; return 1;
if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF)) if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
return 1; return 1;
...@@ -1850,7 +1850,7 @@ static int decode_update_thread_context(AVCodecContext *dst, ...@@ -1850,7 +1850,7 @@ static int decode_update_thread_context(AVCodecContext *dst,
for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) { for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) {
unref_picture(h, &h->DPB[i]); unref_picture(h, &h->DPB[i]);
if (h1->DPB[i].f.data[0] && if (h1->DPB[i].f.buf[0] &&
(ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0) (ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
return ret; return ret;
} }
...@@ -3644,7 +3644,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -3644,7 +3644,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
* since that can modify h->cur_pic_ptr. */ * since that can modify h->cur_pic_ptr. */
if (h0->first_field) { if (h0->first_field) {
assert(h0->cur_pic_ptr); assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.data[0]); assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF); assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* Mark old field/frame as completed */ /* Mark old field/frame as completed */
...@@ -3743,7 +3743,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -3743,7 +3743,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
* frame, or to allocate a new one. */ * frame, or to allocate a new one. */
if (h0->first_field) { if (h0->first_field) {
assert(h0->cur_pic_ptr); assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.data[0]); assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF); assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */ /* figure out if we have a complementary field pair */
...@@ -5174,7 +5174,7 @@ not_extra: ...@@ -5174,7 +5174,7 @@ not_extra:
} }
} }
assert(pict->data[0] || !*got_frame); assert(pict->buf[0] || !*got_frame);
return get_consumed_bytes(buf_index, buf_size); return get_consumed_bytes(buf_index, buf_size);
} }
......
...@@ -141,7 +141,9 @@ int ff_h264_fill_default_ref_list(H264Context *h) ...@@ -141,7 +141,9 @@ int ff_h264_fill_default_ref_list(H264Context *h)
} }
if (lens[0] == lens[1] && lens[1] > 1) { if (lens[0] == lens[1] && lens[1] > 1) {
for (i = 0; h->default_ref_list[0][i].f.data[0] == h->default_ref_list[1][i].f.data[0] && i < lens[0]; i++); for (i = 0; i < lens[0] &&
h->default_ref_list[0][i].f.buf[0]->buffer ==
h->default_ref_list[1][i].f.buf[0]->buffer; i++);
if (i == lens[0]) { if (i == lens[0]) {
Picture tmp; Picture tmp;
COPY_PICTURE(&tmp, &h->default_ref_list[1][0]); COPY_PICTURE(&tmp, &h->default_ref_list[1][0]);
...@@ -304,13 +306,13 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h) ...@@ -304,13 +306,13 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
} }
for (list = 0; list < h->list_count; list++) { for (list = 0; list < h->list_count; list++) {
for (index = 0; index < h->ref_count[list]; index++) { for (index = 0; index < h->ref_count[list]; index++) {
if ( !h->ref_list[list][index].f.data[0] if ( !h->ref_list[list][index].f.buf[0]
|| (!FIELD_PICTURE(h) && (h->ref_list[list][index].reference&3) != 3)) { || (!FIELD_PICTURE(h) && (h->ref_list[list][index].reference&3) != 3)) {
int i; int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc); av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++) for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN; h->last_pocs[i] = INT_MIN;
if (h->default_ref_list[list][0].f.data[0] if (h->default_ref_list[list][0].f.buf[0]
&& !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3)) && !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3))
COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]); COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]);
else else
......
...@@ -241,7 +241,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) ...@@ -241,7 +241,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
r = avcodec_default_get_buffer2(s->avctx, &pic->f, 0); 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", av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
r, pic->f.data[0]); r, pic->f.data[0]);
return -1; return -1;
...@@ -388,7 +388,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) ...@@ -388,7 +388,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
av_assert0(pic->f.data[0]); av_assert0(pic->f.data[0]);
pic->shared = 1; pic->shared = 1;
} else { } else {
av_assert0(!pic->f.data[0]); av_assert0(!pic->f.buf[0]);
if (alloc_frame_buffer(s, pic) < 0) if (alloc_frame_buffer(s, pic) < 0)
return -1; return -1;
...@@ -717,7 +717,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, ...@@ -717,7 +717,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
if(s->picture) if(s->picture)
for (i = 0; i < MAX_PICTURE_COUNT; i++) { for (i = 0; i < MAX_PICTURE_COUNT; i++) {
ff_mpeg_unref_picture(s, &s->picture[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) (ret = ff_mpeg_ref_picture(s, &s->picture[i], &s1->picture[i])) < 0)
return ret; return ret;
} }
...@@ -725,7 +725,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, ...@@ -725,7 +725,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
#define UPDATE_PICTURE(pic)\ #define UPDATE_PICTURE(pic)\
do {\ do {\
ff_mpeg_unref_picture(s, &s->pic);\ 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);\ ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
else\ else\
ret = update_picture_tables(&s->pic, &s1->pic);\ ret = update_picture_tables(&s->pic, &s1->pic);\
...@@ -1424,7 +1424,7 @@ static inline int pic_is_unused(MpegEncContext *s, Picture *pic) ...@@ -1424,7 +1424,7 @@ static inline int pic_is_unused(MpegEncContext *s, Picture *pic)
{ {
if (pic == s->last_picture_ptr) if (pic == s->last_picture_ptr)
return 0; return 0;
if (pic->f.data[0] == NULL) if (pic->f.buf[0] == NULL)
return 1; return 1;
if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF)) if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
return 1; return 1;
...@@ -1437,7 +1437,7 @@ static int find_unused_picture(MpegEncContext *s, int shared) ...@@ -1437,7 +1437,7 @@ static int find_unused_picture(MpegEncContext *s, int shared)
if (shared) { if (shared) {
for (i = 0; i < MAX_PICTURE_COUNT; i++) { for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (s->picture[i].f.data[0] == NULL && &s->picture[i] != s->last_picture_ptr) if (s->picture[i].f.buf[0] == NULL && &s->picture[i] != s->last_picture_ptr)
return i; return i;
} }
} else { } else {
...@@ -1518,7 +1518,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1518,7 +1518,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
/* mark & release old frames */ /* mark & release old frames */
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
s->last_picture_ptr != s->next_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); ff_mpeg_unref_picture(s, s->last_picture_ptr);
} }
...@@ -1543,7 +1543,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1543,7 +1543,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
ff_release_unused_pictures(s, 1); ff_release_unused_pictures(s, 1);
if (s->current_picture_ptr && 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 // we already have a unused image
// (maybe it was set before reading the header) // (maybe it was set before reading the header)
pic = s->current_picture_ptr; pic = s->current_picture_ptr;
...@@ -1603,13 +1603,13 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1603,13 +1603,13 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->pict_type, s->droppable); s->pict_type, s->droppable);
if ((s->last_picture_ptr == NULL || 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->pict_type != AV_PICTURE_TYPE_I ||
s->picture_structure != PICT_FRAME)) { s->picture_structure != PICT_FRAME)) {
int h_chroma_shift, v_chroma_shift; int h_chroma_shift, v_chroma_shift;
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift); &h_chroma_shift, &v_chroma_shift);
if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f.data[0]) if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f.buf[0])
av_log(avctx, AV_LOG_DEBUG, av_log(avctx, AV_LOG_DEBUG,
"allocating dummy last picture for B frame\n"); "allocating dummy last picture for B frame\n");
else if (s->pict_type != AV_PICTURE_TYPE_I) else if (s->pict_type != AV_PICTURE_TYPE_I)
...@@ -1650,7 +1650,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1650,7 +1650,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1); ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);
} }
if ((s->next_picture_ptr == NULL || 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) { s->pict_type == AV_PICTURE_TYPE_B) {
/* Allocate a dummy frame */ /* Allocate a dummy frame */
i = ff_find_unused_picture(s, 0); i = ff_find_unused_picture(s, 0);
...@@ -1674,21 +1674,21 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ...@@ -1674,21 +1674,21 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
#endif #endif
if (s->last_picture_ptr) { if (s->last_picture_ptr) {
ff_mpeg_unref_picture(s, &s->last_picture); 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, (ret = ff_mpeg_ref_picture(s, &s->last_picture,
s->last_picture_ptr)) < 0) s->last_picture_ptr)) < 0)
return ret; return ret;
} }
if (s->next_picture_ptr) { if (s->next_picture_ptr) {
ff_mpeg_unref_picture(s, &s->next_picture); 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, (ret = ff_mpeg_ref_picture(s, &s->next_picture,
s->next_picture_ptr)) < 0) s->next_picture_ptr)) < 0)
return ret; return ret;
} }
av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
s->last_picture_ptr->f.data[0])); s->last_picture_ptr->f.buf[0]));
if (s->picture_structure!= PICT_FRAME) { if (s->picture_structure!= PICT_FRAME) {
int i; int i;
......
...@@ -853,7 +853,7 @@ FF_DISABLE_DEPRECATION_WARNINGS ...@@ -853,7 +853,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
avctx->get_buffer2 == avcodec_default_get_buffer2); avctx->get_buffer2 == avcodec_default_get_buffer2);
FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS
if (!f->f->data[0]) if (!f->f->buf[0])
return; return;
if (avctx->debug & FF_DEBUG_BUFFERS) if (avctx->debug & FF_DEBUG_BUFFERS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment