diff mbox

[FFmpeg-devel] lavf/vc1test: fix vc1test can't probe some RCV file.

Message ID 1539311874-10925-1-git-send-email-mypopydev@gmail.com
State Accepted
Headers show

Commit Message

Jun Zhao Oct. 12, 2018, 2:37 a.m. UTC
case 1:
use the hexdump -C SMM0005.rcv get:
                     size              skip (size - 4)
                      |                        |
                      V                        V
00000000  18 00 00 c5 05 00 00 00  4d f1 0a 11 00 e0 01 00
00000010  00 d0 02 00 00 0c 00 00  00 88 13 00 00 c0 65 52
                         ^
			 |
		     size + 16
case 2:
same the command for SMM0015.rcv get:
                    size
                      |
                      V
00000000  19 00 00 c5 04 00 00 00  41 f3 80 01 40 02 00 00
00000010  d0 02 00 00 0c 00 00 00  00 00 00 10 00 00 00 00
                      ^
		      |
		   size + 16

There are different the RCV file format for VC-1, vc1test
just handle the case 2 now, this fix will support the case 1.
(Both of test clips come from: RP 228:2008 - SMPTE
Recommended Practice - VC-1 Decoder and Bitstream Conformance).

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Yan, FengX <fengx.yan@intel.com>
---
 libavformat/vc1test.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

Comments

Carl Eugen Hoyos Oct. 12, 2018, 9:13 a.m. UTC | #1
2018-10-12 4:37 GMT+02:00, Jun Zhao <mypopydev@gmail.com>:
> case 1:
> use the hexdump -C SMM0005.rcv get:
>                      size              skip (size - 4)
>                       |                        |
>                       V                        V
> 00000000  18 00 00 c5 05 00 00 00  4d f1 0a 11 00 e0 01 00
> 00000010  00 d0 02 00 00 0c 00 00  00 88 13 00 00 c0 65 52
>                          ^
> 			 |
> 		     size + 16
> case 2:
> same the command for SMM0015.rcv get:
>                     size
>                       |
>                       V
> 00000000  19 00 00 c5 04 00 00 00  41 f3 80 01 40 02 00 00
> 00000010  d0 02 00 00 0c 00 00 00  00 00 00 10 00 00 00 00
>                       ^
> 		      |
> 		   size + 16
>
> There are different the RCV file format for VC-1, vc1test
> just handle the case 2 now, this fix will support the case 1.
> (Both of test clips come from: RP 228:2008 - SMPTE
> Recommended Practice - VC-1 Decoder and Bitstream Conformance).
>
> Signed-off-by: Jun Zhao <jun.zhao@intel.com>
> Signed-off-by: Yan, FengX <fengx.yan@intel.com>
> ---
>  libavformat/vc1test.c |   13 +++++++++++--
>  1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c
> index a801f4b..38eb1a4 100644
> --- a/libavformat/vc1test.c
> +++ b/libavformat/vc1test.c
> @@ -34,9 +34,13 @@
>
>  static int vc1t_probe(AVProbeData *p)
>  {
> +    int size;
> +
>      if (p->buf_size < 24)
>          return 0;
> -    if (p->buf[3] != 0xC5 || AV_RL32(&p->buf[4]) != 4 ||
> AV_RL32(&p->buf[20]) != 0xC)
> +
> +    size = AV_RL32(&p->buf[4]);
> +    if (p->buf[3] != 0xC5 || AV_RL32(&p->buf[size+16]) != 0xC)
>          return 0;
>
>      return AVPROBE_SCORE_EXTENSION;
> @@ -48,10 +52,12 @@ static int vc1t_read_header(AVFormatContext *s)
>      AVStream *st;
>      int frames;
>      uint32_t fps;
> +    int size;
>
>      frames = avio_rl24(pb);
> -    if(avio_r8(pb) != 0xC5 || avio_rl32(pb) != 4)

(Maybe it is enough to only change the "!= 4" here?)

> +    if (avio_r8(pb) != 0xC5)
>          return AVERROR_INVALIDDATA;

> +    size = avio_rl32(pb);
>
>      /* init video codec */
>      st = avformat_new_stream(s, NULL);
> @@ -63,6 +69,8 @@ static int vc1t_read_header(AVFormatContext *s)
>
>      if (ff_get_extradata(s, st->codecpar, pb, VC1_EXTRADATA_SIZE) < 0)
>          return AVERROR(ENOMEM);
> +
> +    avio_skip(pb, size - 4);

I may miss something but this looks as if you pass an unchecked
value to avio_skip.

>      st->codecpar->height = avio_rl32(pb);
>      st->codecpar->width = avio_rl32(pb);
>      if(avio_rl32(pb) != 0xC)

> @@ -114,5 +122,6 @@ AVInputFormat ff_vc1t_demuxer = {
>      .read_probe     = vc1t_probe,
>      .read_header    = vc1t_read_header,
>      .read_packet    = vc1t_read_packet,
> +     .extensions    = "rcv",

This is an unrelated change that should not be part of this patch.

Carl Eugen
Jun Zhao Oct. 12, 2018, 12:45 p.m. UTC | #2
On Fri, Oct 12, 2018 at 5:19 PM Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2018-10-12 4:37 GMT+02:00, Jun Zhao <mypopydev@gmail.com>:
> > case 1:
> > use the hexdump -C SMM0005.rcv get:
> >                      size              skip (size - 4)
> >                       |                        |
> >                       V                        V
> > 00000000  18 00 00 c5 05 00 00 00  4d f1 0a 11 00 e0 01 00
> > 00000010  00 d0 02 00 00 0c 00 00  00 88 13 00 00 c0 65 52
> >                          ^
> >                        |
> >                    size + 16
> > case 2:
> > same the command for SMM0015.rcv get:
> >                     size
> >                       |
> >                       V
> > 00000000  19 00 00 c5 04 00 00 00  41 f3 80 01 40 02 00 00
> > 00000010  d0 02 00 00 0c 00 00 00  00 00 00 10 00 00 00 00
> >                       ^
> >                     |
> >                  size + 16
> >
> > There are different the RCV file format for VC-1, vc1test
> > just handle the case 2 now, this fix will support the case 1.
> > (Both of test clips come from: RP 228:2008 - SMPTE
> > Recommended Practice - VC-1 Decoder and Bitstream Conformance).
> >
> > Signed-off-by: Jun Zhao <jun.zhao@intel.com>
> > Signed-off-by: Yan, FengX <fengx.yan@intel.com>
> > ---
> >  libavformat/vc1test.c |   13 +++++++++++--
> >  1 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c
> > index a801f4b..38eb1a4 100644
> > --- a/libavformat/vc1test.c
> > +++ b/libavformat/vc1test.c
> > @@ -34,9 +34,13 @@
> >
> >  static int vc1t_probe(AVProbeData *p)
> >  {
> > +    int size;
> > +
> >      if (p->buf_size < 24)
> >          return 0;
> > -    if (p->buf[3] != 0xC5 || AV_RL32(&p->buf[4]) != 4 ||
> > AV_RL32(&p->buf[20]) != 0xC)
> > +
> > +    size = AV_RL32(&p->buf[4]);
> > +    if (p->buf[3] != 0xC5 || AV_RL32(&p->buf[size+16]) != 0xC)
> >          return 0;
> >
> >      return AVPROBE_SCORE_EXTENSION;
> > @@ -48,10 +52,12 @@ static int vc1t_read_header(AVFormatContext *s)
> >      AVStream *st;
> >      int frames;
> >      uint32_t fps;
> > +    int size;
> >
> >      frames = avio_rl24(pb);
> > -    if(avio_r8(pb) != 0xC5 || avio_rl32(pb) != 4)
>
> (Maybe it is enough to only change the "!= 4" here?)
>
> Maybe   avio_rl32(pb) >= 4 ?

> > +    if (avio_r8(pb) != 0xC5)
> >          return AVERROR_INVALIDDATA;
>
> > +    size = avio_rl32(pb);
> >
> >      /* init video codec */
> >      st = avformat_new_stream(s, NULL);
> > @@ -63,6 +69,8 @@ static int vc1t_read_header(AVFormatContext *s)
> >
> >      if (ff_get_extradata(s, st->codecpar, pb, VC1_EXTRADATA_SIZE) < 0)
> >          return AVERROR(ENOMEM);
> > +
> > +    avio_skip(pb, size - 4);
>
> I may miss something but this looks as if you pass an unchecked
> value to avio_skip.
>
> Will add a check before the avio_skip.


> >      st->codecpar->height = avio_rl32(pb);
> >      st->codecpar->width = avio_rl32(pb);
> >      if(avio_rl32(pb) != 0xC)
>
> > @@ -114,5 +122,6 @@ AVInputFormat ff_vc1t_demuxer = {
> >      .read_probe     = vc1t_probe,
> >      .read_header    = vc1t_read_header,
> >      .read_packet    = vc1t_read_packet,
> > +     .extensions    = "rcv",
>
> This is an unrelated change that should not be part of this patch.
>
Will split to the other patch for this change.

>
> Carl Eugen
> _______________________________________________
>
diff mbox

Patch

diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c
index a801f4b..38eb1a4 100644
--- a/libavformat/vc1test.c
+++ b/libavformat/vc1test.c
@@ -34,9 +34,13 @@ 
 
 static int vc1t_probe(AVProbeData *p)
 {
+    int size;
+
     if (p->buf_size < 24)
         return 0;
-    if (p->buf[3] != 0xC5 || AV_RL32(&p->buf[4]) != 4 || AV_RL32(&p->buf[20]) != 0xC)
+
+    size = AV_RL32(&p->buf[4]);
+    if (p->buf[3] != 0xC5 || AV_RL32(&p->buf[size+16]) != 0xC)
         return 0;
 
     return AVPROBE_SCORE_EXTENSION;
@@ -48,10 +52,12 @@  static int vc1t_read_header(AVFormatContext *s)
     AVStream *st;
     int frames;
     uint32_t fps;
+    int size;
 
     frames = avio_rl24(pb);
-    if(avio_r8(pb) != 0xC5 || avio_rl32(pb) != 4)
+    if (avio_r8(pb) != 0xC5)
         return AVERROR_INVALIDDATA;
+    size = avio_rl32(pb);
 
     /* init video codec */
     st = avformat_new_stream(s, NULL);
@@ -63,6 +69,8 @@  static int vc1t_read_header(AVFormatContext *s)
 
     if (ff_get_extradata(s, st->codecpar, pb, VC1_EXTRADATA_SIZE) < 0)
         return AVERROR(ENOMEM);
+
+    avio_skip(pb, size - 4);
     st->codecpar->height = avio_rl32(pb);
     st->codecpar->width = avio_rl32(pb);
     if(avio_rl32(pb) != 0xC)
@@ -114,5 +122,6 @@  AVInputFormat ff_vc1t_demuxer = {
     .read_probe     = vc1t_probe,
     .read_header    = vc1t_read_header,
     .read_packet    = vc1t_read_packet,
+     .extensions    = "rcv",
     .flags          = AVFMT_GENERIC_INDEX,
 };