diff mbox series

[FFmpeg-devel,1/2] avformat/flvenc: use extract_extradata bsf when necessary

Message ID tencent_8938CC16694D50A037CDEC4FB9D56B272507@qq.com
State Accepted
Commit 34b8af796341887766cfa02fe5f4383039919bb6
Headers show
Series [FFmpeg-devel,1/2] avformat/flvenc: use extract_extradata bsf when necessary | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Zhao Zhili March 15, 2023, 4:27 p.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

---
 libavformat/flvenc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Zhao Zhili April 9, 2023, 2:13 p.m. UTC | #1
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Zhao Zhili
> Sent: 2023年3月16日 0:28
> To: ffmpeg-devel@ffmpeg.org
> Cc: Zhao Zhili <zhilizhao@tencent.com>
> Subject: [FFmpeg-devel] [PATCH 1/2] avformat/flvenc: use extract_extradata bsf when necessary
> 
> From: Zhao Zhili <zhilizhao@tencent.com>
> 
> ---
>  libavformat/flvenc.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index 64ea554dad..fbf7eabaf8 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -1023,13 +1023,15 @@ fail:
>  static int flv_check_bitstream(AVFormatContext *s, AVStream *st,
>                                 const AVPacket *pkt)
>  {
> -    int ret = 1;
> -
>      if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
>          if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0)
> -            ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
> +            return ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
>      }
> -    return ret;
> +    if (!st->codecpar->extradata_size &&
> +            (st->codecpar->codec_id == AV_CODEC_ID_H264 ||
> +             st->codecpar->codec_id == AV_CODEC_ID_MPEG4))
> +        return ff_stream_add_bitstream_filter(st, "extract_extradata", NULL);
> +    return 1;
>  }
> 
>  static void flv_deinit(AVFormatContext *s)
> --

Pushed as 34b8af79 and 862a626.
diff mbox series

Patch

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 64ea554dad..fbf7eabaf8 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -1023,13 +1023,15 @@  fail:
 static int flv_check_bitstream(AVFormatContext *s, AVStream *st,
                                const AVPacket *pkt)
 {
-    int ret = 1;
-
     if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
         if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0)
-            ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
+            return ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
     }
-    return ret;
+    if (!st->codecpar->extradata_size &&
+            (st->codecpar->codec_id == AV_CODEC_ID_H264 ||
+             st->codecpar->codec_id == AV_CODEC_ID_MPEG4))
+        return ff_stream_add_bitstream_filter(st, "extract_extradata", NULL);
+    return 1;
 }
 
 static void flv_deinit(AVFormatContext *s)