diff mbox series

[FFmpeg-devel,6/7] avformat/apm: name and probe fix

Message ID 20200609001730.961175-7-zane@zanevaniperen.com
State Superseded
Headers show
Series adpcm_ima_apm encoder + apm muxer | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Zane van Iperen June 9, 2020, 12:19 a.m. UTC
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavformat/apm.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Andreas Rheinhardt June 10, 2020, 6:47 p.m. UTC | #1
Zane van Iperen:
> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
> ---
>  libavformat/apm.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/apm.c b/libavformat/apm.c
> index 46a0c67b79..8ece104ae7 100644
> --- a/libavformat/apm.c
> +++ b/libavformat/apm.c
> @@ -31,8 +31,8 @@
>  #define APM_EXTRADATA_SIZE      28
>  
>  #define APM_MAX_READ_SIZE       4096
> -#define APM_CODEC_TAG           0x2000
>  
> +#define APM_TAG_CODEC           0x2000
>  #define APM_TAG_VS12            MKTAG('v', 's', '1', '2')
>  #define APM_TAG_DATA            MKTAG('D', 'A', 'T', 'A')
>  
> @@ -82,6 +82,9 @@ static void apm_parse_extradata(APMExtraData *ed, const uint8_t *buf)
>  
>  static int apm_probe(const AVProbeData *p)
>  {
> +    if (AV_RL16(p->buf) != APM_TAG_CODEC)
> +        return 0;
> +
>      if (p->buf_size < 100)
>          return 0;
>  
> @@ -109,7 +112,7 @@ static int apm_read_header(AVFormatContext *s)
>       * This is 98% a WAVEFORMATEX, but there's something screwy with the extradata
>       * that ff_get_wav_header() can't (and shouldn't) handle properly.
>       */
> -    if (avio_rl16(s->pb) != APM_CODEC_TAG)
> +    if (avio_rl16(s->pb) != APM_TAG_CODEC)
>          return AVERROR_INVALIDDATA;
>  
>      par = st->codecpar;
> @@ -248,7 +251,7 @@ static int apm_write_header(AVFormatContext *s)
>       * Bodge a WAVEFORMATEX manually, ff_put_wav_header() can't
>       * be used because of the extra 2 bytes.
>       */
> -    avio_wl16(s->pb, APM_CODEC_TAG);
> +    avio_wl16(s->pb, APM_TAG_CODEC);
>      avio_wl16(s->pb, par->channels);
>      avio_wl32(s->pb, par->sample_rate);
>      avio_wl32(s->pb, par->sample_rate * par->channels * 2);
> 
Why is this patch not applied before the addition of the muxer? If the
order were reversed, apm_write_header wouldn't need to be modified
immediately afterwards.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/apm.c b/libavformat/apm.c
index 46a0c67b79..8ece104ae7 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -31,8 +31,8 @@ 
 #define APM_EXTRADATA_SIZE      28
 
 #define APM_MAX_READ_SIZE       4096
-#define APM_CODEC_TAG           0x2000
 
+#define APM_TAG_CODEC           0x2000
 #define APM_TAG_VS12            MKTAG('v', 's', '1', '2')
 #define APM_TAG_DATA            MKTAG('D', 'A', 'T', 'A')
 
@@ -82,6 +82,9 @@  static void apm_parse_extradata(APMExtraData *ed, const uint8_t *buf)
 
 static int apm_probe(const AVProbeData *p)
 {
+    if (AV_RL16(p->buf) != APM_TAG_CODEC)
+        return 0;
+
     if (p->buf_size < 100)
         return 0;
 
@@ -109,7 +112,7 @@  static int apm_read_header(AVFormatContext *s)
      * This is 98% a WAVEFORMATEX, but there's something screwy with the extradata
      * that ff_get_wav_header() can't (and shouldn't) handle properly.
      */
-    if (avio_rl16(s->pb) != APM_CODEC_TAG)
+    if (avio_rl16(s->pb) != APM_TAG_CODEC)
         return AVERROR_INVALIDDATA;
 
     par = st->codecpar;
@@ -248,7 +251,7 @@  static int apm_write_header(AVFormatContext *s)
      * Bodge a WAVEFORMATEX manually, ff_put_wav_header() can't
      * be used because of the extra 2 bytes.
      */
-    avio_wl16(s->pb, APM_CODEC_TAG);
+    avio_wl16(s->pb, APM_TAG_CODEC);
     avio_wl16(s->pb, par->channels);
     avio_wl32(s->pb, par->sample_rate);
     avio_wl32(s->pb, par->sample_rate * par->channels * 2);