[FFmpeg-devel] avformat/flac_picture: try to guess PNG by actual picture data

Submitted by Paul B Mahol on Dec. 13, 2018, 7:15 p.m.

Details

Message ID 20181213191502.3199-1-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol Dec. 13, 2018, 7:15 p.m.
Fixes #5028.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/flac_picture.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

James Almer Dec. 13, 2018, 7:52 p.m.
On 12/13/2018 4:15 PM, Paul B Mahol wrote:
> Fixes #5028.
> 
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/flac_picture.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/flac_picture.c b/libavformat/flac_picture.c
> index 38982b960d..6698d4ea6a 100644
> --- a/libavformat/flac_picture.c
> +++ b/libavformat/flac_picture.c
> @@ -20,6 +20,7 @@
>   */
>  
>  #include "libavutil/avassert.h"
> +#include "libavutil/intreadwrite.h"
>  #include "avformat.h"
>  #include "flac_picture.h"
>  #include "id3v2.h"
> @@ -119,6 +120,9 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
>          goto fail;
>      }
>  
> +    if (AV_RB64(data->data) == 0x89504e470d0a1a0a)

Include libavcodec/png.h and use PNGSIG instead?

> +        id = AV_CODEC_ID_PNG;
> +
>      st = avformat_new_stream(s, NULL);
>      if (!st) {
>          RETURN_ERROR(AVERROR(ENOMEM));
>

Patch hide | download patch | download mbox

diff --git a/libavformat/flac_picture.c b/libavformat/flac_picture.c
index 38982b960d..6698d4ea6a 100644
--- a/libavformat/flac_picture.c
+++ b/libavformat/flac_picture.c
@@ -20,6 +20,7 @@ 
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "flac_picture.h"
 #include "id3v2.h"
@@ -119,6 +120,9 @@  int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
         goto fail;
     }
 
+    if (AV_RB64(data->data) == 0x89504e470d0a1a0a)
+        id = AV_CODEC_ID_PNG;
+
     st = avformat_new_stream(s, NULL);
     if (!st) {
         RETURN_ERROR(AVERROR(ENOMEM));