Re: [FFmpeg-devel] [PATCH] vp9: use AVFrame.buf[0] to check if a frame is valid

2015-10-16 Thread Hendrik Leppkes
On Thu, Oct 15, 2015 at 2:52 PM, Ronald S. Bultje  wrote:
> Hi,
>
> On Thu, Oct 15, 2015 at 8:02 AM, Hendrik Leppkes 
> wrote:
>
>> AVFrame.data[0] is not guaranteed to be set with a HWAccel
>> ---
>>  libavcodec/vp9.c | 46 +++---
>>  1 file changed, 23 insertions(+), 23 deletions(-)
>
>
> Obscure. But OK. Is this documented in the AVFrame API?
>

Pushed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] vp9: use AVFrame.buf[0] to check if a frame is valid

2015-10-15 Thread Hendrik Leppkes
AVFrame.data[0] is not guaranteed to be set with a HWAccel
---
 libavcodec/vp9.c | 46 +++---
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 27fb956..3753e89 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -527,9 +527,9 @@ static int decode_frame_header(AVCodecContext *ctx,
 s->s.h.signbias[1]= get_bits1(>gb) && !s->s.h.errorres;
 s->s.h.refidx[2]  = get_bits(>gb, 3);
 s->s.h.signbias[2]= get_bits1(>gb) && !s->s.h.errorres;
-if (!s->s.refs[s->s.h.refidx[0]].f->data[0] ||
-!s->s.refs[s->s.h.refidx[1]].f->data[0] ||
-!s->s.refs[s->s.h.refidx[2]].f->data[0]) {
+if (!s->s.refs[s->s.h.refidx[0]].f->buf[0] ||
+!s->s.refs[s->s.h.refidx[1]].f->buf[0] ||
+!s->s.refs[s->s.h.refidx[2]].f->buf[0]) {
 av_log(ctx, AV_LOG_ERROR, "Not all references are 
available\n");
 return AVERROR_INVALIDDATA;
 }
@@ -3880,15 +3880,15 @@ static av_cold int vp9_decode_free(AVCodecContext *ctx)
 int i;
 
 for (i = 0; i < 3; i++) {
-if (s->s.frames[i].tf.f->data[0])
+if (s->s.frames[i].tf.f->buf[0])
 vp9_unref_frame(ctx, >s.frames[i]);
 av_frame_free(>s.frames[i].tf.f);
 }
 for (i = 0; i < 8; i++) {
-if (s->s.refs[i].f->data[0])
+if (s->s.refs[i].f->buf[0])
 ff_thread_release_buffer(ctx, >s.refs[i]);
 av_frame_free(>s.refs[i].f);
-if (s->next_refs[i].f->data[0])
+if (s->next_refs[i].f->buf[0])
 ff_thread_release_buffer(ctx, >next_refs[i]);
 av_frame_free(>next_refs[i].f);
 }
@@ -3916,7 +3916,7 @@ static int vp9_decode_frame(AVCodecContext *ctx, void 
*frame,
 if ((res = decode_frame_header(ctx, data, size, )) < 0) {
 return res;
 } else if (res == 0) {
-if (!s->s.refs[ref].f->data[0]) {
+if (!s->s.refs[ref].f->buf[0]) {
 av_log(ctx, AV_LOG_ERROR, "Requested reference %d not 
available\n", ref);
 return AVERROR_INVALIDDATA;
 }
@@ -3925,9 +3925,9 @@ static int vp9_decode_frame(AVCodecContext *ctx, void 
*frame,
 ((AVFrame *)frame)->pkt_pts = pkt->pts;
 ((AVFrame *)frame)->pkt_dts = pkt->dts;
 for (i = 0; i < 8; i++) {
-if (s->next_refs[i].f->data[0])
+if (s->next_refs[i].f->buf[0])
 ff_thread_release_buffer(ctx, >next_refs[i]);
-if (s->s.refs[i].f->data[0] &&
+if (s->s.refs[i].f->buf[0] &&
 (res = ff_thread_ref_frame(>next_refs[i], >s.refs[i])) < 
0)
 return res;
 }
@@ -3938,18 +3938,18 @@ static int vp9_decode_frame(AVCodecContext *ctx, void 
*frame,
 size -= res;
 
 if (!retain_segmap_ref || s->s.h.keyframe || s->s.h.intraonly) {
-if (s->s.frames[REF_FRAME_SEGMAP].tf.f->data[0])
+if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0])
 vp9_unref_frame(ctx, >s.frames[REF_FRAME_SEGMAP]);
-if (!s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres && 
s->s.frames[CUR_FRAME].tf.f->data[0] &&
+if (!s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres && 
s->s.frames[CUR_FRAME].tf.f->buf[0] &&
 (res = vp9_ref_frame(ctx, >s.frames[REF_FRAME_SEGMAP], 
>s.frames[CUR_FRAME])) < 0)
 return res;
 }
-if (s->s.frames[REF_FRAME_MVPAIR].tf.f->data[0])
+if (s->s.frames[REF_FRAME_MVPAIR].tf.f->buf[0])
 vp9_unref_frame(ctx, >s.frames[REF_FRAME_MVPAIR]);
-if (!s->s.h.intraonly && !s->s.h.keyframe && !s->s.h.errorres && 
s->s.frames[CUR_FRAME].tf.f->data[0] &&
+if (!s->s.h.intraonly && !s->s.h.keyframe && !s->s.h.errorres && 
s->s.frames[CUR_FRAME].tf.f->buf[0] &&
 (res = vp9_ref_frame(ctx, >s.frames[REF_FRAME_MVPAIR], 
>s.frames[CUR_FRAME])) < 0)
 return res;
-if (s->s.frames[CUR_FRAME].tf.f->data[0])
+if (s->s.frames[CUR_FRAME].tf.f->buf[0])
 vp9_unref_frame(ctx, >s.frames[CUR_FRAME]);
 if ((res = vp9_alloc_frame(ctx, >s.frames[CUR_FRAME])) < 0)
 return res;
@@ -3959,7 +3959,7 @@ static int vp9_decode_frame(AVCodecContext *ctx, void 
*frame,
 ls_y = f->linesize[0];
 ls_uv =f->linesize[1];
 
-if (s->s.frames[REF_FRAME_SEGMAP].tf.f->data[0] &&
+if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0] &&
 (s->s.frames[REF_FRAME_MVPAIR].tf.f->width  != 
s->s.frames[CUR_FRAME].tf.f->width ||
  s->s.frames[REF_FRAME_MVPAIR].tf.f->height != 
s->s.frames[CUR_FRAME].tf.f->height)) {
 vp9_unref_frame(ctx, >s.frames[REF_FRAME_SEGMAP]);
@@ -3967,11 +3967,11 @@ static int vp9_decode_frame(AVCodecContext *ctx, void 
*frame,
 
 // ref frame setup
 for (i = 0; i < 8; i++) {
-if (s->next_refs[i].f->data[0])
+if (s->next_refs[i].f->buf[0])
 ff_thread_release_buffer(ctx, 

Re: [FFmpeg-devel] [PATCH] vp9: use AVFrame.buf[0] to check if a frame is valid

2015-10-15 Thread Ronald S. Bultje
Hi,

On Thu, Oct 15, 2015 at 8:02 AM, Hendrik Leppkes 
wrote:

> AVFrame.data[0] is not guaranteed to be set with a HWAccel
> ---
>  libavcodec/vp9.c | 46 +++---
>  1 file changed, 23 insertions(+), 23 deletions(-)


Obscure. But OK. Is this documented in the AVFrame API?

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] vp9: use AVFrame.buf[0] to check if a frame is valid

2015-10-15 Thread wm4
On Thu, 15 Oct 2015 08:52:33 -0400
"Ronald S. Bultje"  wrote:

> Hi,
> 
> On Thu, Oct 15, 2015 at 8:02 AM, Hendrik Leppkes 
> wrote:
> 
> > AVFrame.data[0] is not guaranteed to be set with a HWAccel
> > ---
> >  libavcodec/vp9.c | 46 +++---
> >  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> 
> Obscure. But OK. Is this documented in the AVFrame API?

It kind of follows from its documentation. Nothing says that data[0]
has to be set, while buf[0] _must_ be set if the frame is refcounted.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel