diff mbox

[FFmpeg-devel,1/3] hevc: Allow parsing external extradata buffers

Message ID 20161108220328.7397-1-vittorio.giovara@gmail.com
State Accepted
Headers show

Commit Message

Vittorio Giovara Nov. 8, 2016, 10:03 p.m. UTC
---
As mentioned in the discussion.
Please CC.
Vittorio

 libavcodec/hevc.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Vittorio Giovara Nov. 17, 2016, 3:38 p.m. UTC | #1
On Tue, Nov 8, 2016 at 5:03 PM, Vittorio Giovara
<vittorio.giovara@gmail.com> wrote:
> ---
> As mentioned in the discussion.
> Please CC.
> Vittorio
>
>  libavcodec/hevc.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
> index 29e0d49..02fd606 100644
> --- a/libavcodec/hevc.c
> +++ b/libavcodec/hevc.c
> @@ -2973,17 +2973,15 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
>      return 0;
>  }
>
> -static int hevc_decode_extradata(HEVCContext *s)
> +static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)
>  {
>      AVCodecContext *avctx = s->avctx;
>      GetByteContext gb;
>      int ret, i;
>
> -    bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
> +    bytestream2_init(&gb, buf, length);
>
> -    if (avctx->extradata_size > 3 &&
> -        (avctx->extradata[0] || avctx->extradata[1] ||
> -         avctx->extradata[2] > 1)) {
> +    if (avctx->extradata_size > 3 && (buf[0] || buf[1] || buf[2] > 1)) {
>          /* It seems the extradata is encoded as hvcC format.
>           * Temporarily, we support configurationVersion==0 until 14496-15 3rd
>           * is finalized. When finalized, configurationVersion will be 1 and we
> @@ -3030,7 +3028,7 @@ static int hevc_decode_extradata(HEVCContext *s)
>          s->nal_length_size = nal_len_size;
>      } else {
>          s->is_nalff = 0;
> -        ret = decode_nal_units(s, avctx->extradata, avctx->extradata_size);
> +        ret = decode_nal_units(s, buf, length);
>          if (ret < 0)
>              return ret;
>      }
> @@ -3338,7 +3336,7 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
>          s->threads_number = 1;
>
>      if (avctx->extradata_size > 0 && avctx->extradata) {
> -        ret = hevc_decode_extradata(s);
> +        ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size);
>          if (ret < 0) {
>              hevc_decode_free(avctx);
>              return ret;
> --
> 2.10.0
>

ping
Michael Niedermayer Nov. 29, 2016, 2:01 a.m. UTC | #2
On Tue, Nov 08, 2016 at 05:03:26PM -0500, Vittorio Giovara wrote:
> ---
> As mentioned in the discussion.
> Please CC.
> Vittorio
> 
>  libavcodec/hevc.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
> index 29e0d49..02fd606 100644
> --- a/libavcodec/hevc.c
> +++ b/libavcodec/hevc.c
> @@ -2973,17 +2973,15 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
>      return 0;
>  }
>  
> -static int hevc_decode_extradata(HEVCContext *s)
> +static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)
>  {
>      AVCodecContext *avctx = s->avctx;
>      GetByteContext gb;
>      int ret, i;
>  
> -    bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
> +    bytestream2_init(&gb, buf, length);
>  
> -    if (avctx->extradata_size > 3 &&
> -        (avctx->extradata[0] || avctx->extradata[1] ||
> -         avctx->extradata[2] > 1)) {
> +    if (avctx->extradata_size > 3 && (buf[0] || buf[1] || buf[2] > 1)) {
           ^^^^^^^^^^^^^^^^^^^^^

is that intended to stay extradata_size ?

[...]
Michael Niedermayer Nov. 29, 2016, 2:07 a.m. UTC | #3
On Tue, Nov 29, 2016 at 03:01:28AM +0100, Michael Niedermayer wrote:
> On Tue, Nov 08, 2016 at 05:03:26PM -0500, Vittorio Giovara wrote:
> > ---
> > As mentioned in the discussion.
> > Please CC.
> > Vittorio
> > 
> >  libavcodec/hevc.c | 12 +++++-------
> >  1 file changed, 5 insertions(+), 7 deletions(-)
> > 
> > diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
> > index 29e0d49..02fd606 100644
> > --- a/libavcodec/hevc.c
> > +++ b/libavcodec/hevc.c
> > @@ -2973,17 +2973,15 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
> >      return 0;
> >  }
> >  
> > -static int hevc_decode_extradata(HEVCContext *s)
> > +static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)
> >  {
> >      AVCodecContext *avctx = s->avctx;
> >      GetByteContext gb;
> >      int ret, i;
> >  
> > -    bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
> > +    bytestream2_init(&gb, buf, length);
> >  
> > -    if (avctx->extradata_size > 3 &&
> > -        (avctx->extradata[0] || avctx->extradata[1] ||
> > -         avctx->extradata[2] > 1)) {
> > +    if (avctx->extradata_size > 3 && (buf[0] || buf[1] || buf[2] > 1)) {
>            ^^^^^^^^^^^^^^^^^^^^^
> 
> is that intended to stay extradata_size ?

and like always i forget the CC :(

[...]
Vittorio Giovara Nov. 29, 2016, 3:02 a.m. UTC | #4
On Mon, Nov 28, 2016 at 9:07 PM, Michael Niedermayer
<michael@niedermayer.cc> wrote:
> On Tue, Nov 29, 2016 at 03:01:28AM +0100, Michael Niedermayer wrote:
>> On Tue, Nov 08, 2016 at 05:03:26PM -0500, Vittorio Giovara wrote:
>> > ---
>> > As mentioned in the discussion.
>> > Please CC.
>> > Vittorio
>> >
>> >  libavcodec/hevc.c | 12 +++++-------
>> >  1 file changed, 5 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
>> > index 29e0d49..02fd606 100644
>> > --- a/libavcodec/hevc.c
>> > +++ b/libavcodec/hevc.c
>> > @@ -2973,17 +2973,15 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
>> >      return 0;
>> >  }
>> >
>> > -static int hevc_decode_extradata(HEVCContext *s)
>> > +static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)
>> >  {
>> >      AVCodecContext *avctx = s->avctx;
>> >      GetByteContext gb;
>> >      int ret, i;
>> >
>> > -    bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
>> > +    bytestream2_init(&gb, buf, length);
>> >
>> > -    if (avctx->extradata_size > 3 &&
>> > -        (avctx->extradata[0] || avctx->extradata[1] ||
>> > -         avctx->extradata[2] > 1)) {
>> > +    if (avctx->extradata_size > 3 && (buf[0] || buf[1] || buf[2] > 1)) {
>>            ^^^^^^^^^^^^^^^^^^^^^
>>
>> is that intended to stay extradata_size ?

ops, no, good catch

applied
>> > +    if (length > 3 && (buf[0] || buf[1] || buf[2] > 1)) {
locally, thanks
diff mbox

Patch

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 29e0d49..02fd606 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2973,17 +2973,15 @@  static int verify_md5(HEVCContext *s, AVFrame *frame)
     return 0;
 }
 
-static int hevc_decode_extradata(HEVCContext *s)
+static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)
 {
     AVCodecContext *avctx = s->avctx;
     GetByteContext gb;
     int ret, i;
 
-    bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
+    bytestream2_init(&gb, buf, length);
 
-    if (avctx->extradata_size > 3 &&
-        (avctx->extradata[0] || avctx->extradata[1] ||
-         avctx->extradata[2] > 1)) {
+    if (avctx->extradata_size > 3 && (buf[0] || buf[1] || buf[2] > 1)) {
         /* It seems the extradata is encoded as hvcC format.
          * Temporarily, we support configurationVersion==0 until 14496-15 3rd
          * is finalized. When finalized, configurationVersion will be 1 and we
@@ -3030,7 +3028,7 @@  static int hevc_decode_extradata(HEVCContext *s)
         s->nal_length_size = nal_len_size;
     } else {
         s->is_nalff = 0;
-        ret = decode_nal_units(s, avctx->extradata, avctx->extradata_size);
+        ret = decode_nal_units(s, buf, length);
         if (ret < 0)
             return ret;
     }
@@ -3338,7 +3336,7 @@  static av_cold int hevc_decode_init(AVCodecContext *avctx)
         s->threads_number = 1;
 
     if (avctx->extradata_size > 0 && avctx->extradata) {
-        ret = hevc_decode_extradata(s);
+        ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size);
         if (ret < 0) {
             hevc_decode_free(avctx);
             return ret;