Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
       [not found] <306722>
@ 2023-02-18 17:49 ` Marth64
  2023-02-18 18:59   ` Hendrik Leppkes
  0 siblings, 1 reply; 8+ messages in thread
From: Marth64 @ 2023-02-18 17:49 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marth64

Signed-off-by: Marth64 <marth64@proxyid.net>
---
- Missed adding the profiles to actual codec descriptor in ac3dec_float
- Formatting tidyness

 libavcodec/ac3dec.c       |  3 +++
 libavcodec/ac3dec.h       |  1 +
 libavcodec/ac3dec_float.c |  2 ++
 libavcodec/avcodec.h      |  2 ++
 libavcodec/codec_desc.c   |  1 +
 libavcodec/eac3dec.c      | 11 ++++++++++-
 libavcodec/profiles.c     |  5 +++++
 libavcodec/profiles.h     |  1 +
 8 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..b5f4b166d3 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1714,6 +1714,9 @@ skip:
     if (!err) {
         avctx->sample_rate = s->sample_rate;
         avctx->bit_rate    = s->bit_rate + s->prev_bit_rate;
+
+        if (s->eac3_extension_type_a == 1)
+            avctx->profile = s->eac3_extension_type_a == 1 ? FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;
     }
 
     if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
     int eac3;                               ///< indicates if current frame is E-AC-3
     int eac3_frame_dependent_found;         ///< bitstream has E-AC-3 dependent frame(s)
     int eac3_subsbtreamid_found;            ///< bitstream has E-AC-3 additional substream(s)
+    int eac3_extension_type_a;              ///< bitstream has E-AC-3 extension type A enabled frame(s)
     int dolby_surround_mode;                ///< dolby surround mode                    (dsurmod)
     int dolby_surround_ex_mode;             ///< dolby surround ex mode                 (dsurexmod)
     int dolby_headphone_mode;               ///< dolby headphone mode                   (dheadphonmod)
diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c
index b8868d8ee1..39d3cbd282 100644
--- a/libavcodec/ac3dec_float.c
+++ b/libavcodec/ac3dec_float.c
@@ -33,6 +33,7 @@
 
 #include "ac3dec.h"
 #include "codec_internal.h"
+#include "profiles.h"
 #include "eac3dec.c"
 #include "ac3dec.c"
 
@@ -92,6 +93,7 @@ const FFCodec ff_eac3_decoder = {
     .p.sample_fmts  = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
     .p.priv_class   = &ac3_eac3_decoder_class,
+    .p.profiles     = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 39881a1d2b..0e85dd50a4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1591,6 +1591,8 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_DTS_HD_MA   60
 #define FF_PROFILE_DTS_EXPRESS 70
 
+#define FF_PROFILE_EAC3_DDP_ATMOS         30
+
 #define FF_PROFILE_MPEG2_422    0
 #define FF_PROFILE_MPEG2_HIGH   1
 #define FF_PROFILE_MPEG2_SS     2
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 199f62df15..4098d4f5a5 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
         .name      = "eac3",
         .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+        .profiles  = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
     },
     {
         .id        = AV_CODEC_ID_SIPR,
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
     if (get_bits1(gbc)) {
         int addbsil = get_bits(gbc, 6);
         for (i = 0; i < addbsil + 1; i++) {
-            skip_bits(gbc, 8); // skip additional bit stream info
+            if (i == 0) {
+                /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+                   which can be used to detect Atmos presence */
+                skip_bits(gbc, 7);
+                if (get_bits1(gbc)) {
+                    s->eac3_extension_type_a = 1;
+                }
+            } else {
+                skip_bits(gbc, 8); // skip additional bit stream info
+            }
         }
     }
 
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..343b08f363 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = {
     { FF_PROFILE_UNKNOWN },
 };
 
+const AVProfile ff_eac3_profiles[] = {
+  { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+  { FF_PROFILE_UNKNOWN },
+};
+
 const AVProfile ff_dnxhd_profiles[] = {
   { FF_PROFILE_DNXHD,      "DNXHD"},
   { FF_PROFILE_DNXHR_LB,   "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..6ebedbd03f 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,7 @@
 
 extern const AVProfile ff_aac_profiles[];
 extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
 extern const AVProfile ff_dnxhd_profiles[];
 extern const AVProfile ff_h264_profiles[];
 extern const AVProfile ff_hevc_profiles[];
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
  2023-02-18 17:49 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
@ 2023-02-18 18:59   ` Hendrik Leppkes
  2023-02-18 19:35     ` Marth64
  0 siblings, 1 reply; 8+ messages in thread
From: Hendrik Leppkes @ 2023-02-18 18:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Feb 18, 2023 at 6:50 PM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
> - Missed adding the profiles to actual codec descriptor in ac3dec_float
> - Formatting tidyness
>
>  libavcodec/ac3dec.c       |  3 +++
>  libavcodec/ac3dec.h       |  1 +
>  libavcodec/ac3dec_float.c |  2 ++
>  libavcodec/avcodec.h      |  2 ++
>  libavcodec/codec_desc.c   |  1 +
>  libavcodec/eac3dec.c      | 11 ++++++++++-
>  libavcodec/profiles.c     |  5 +++++
>  libavcodec/profiles.h     |  1 +
>  8 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
> index 0b120e6140..b5f4b166d3 100644
> --- a/libavcodec/ac3dec.c
> +++ b/libavcodec/ac3dec.c
> @@ -1714,6 +1714,9 @@ skip:
>      if (!err) {
>          avctx->sample_rate = s->sample_rate;
>          avctx->bit_rate    = s->bit_rate + s->prev_bit_rate;
> +
> +        if (s->eac3_extension_type_a == 1)
> +            avctx->profile = s->eac3_extension_type_a == 1 ? FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;
>      }

You have to leave out the if(..) for this to make sense. :)
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
  2023-02-18 18:59   ` Hendrik Leppkes
@ 2023-02-18 19:35     ` Marth64
  0 siblings, 0 replies; 8+ messages in thread
From: Marth64 @ 2023-02-18 19:35 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Embarrassing, good eye. Fixing now!

On Sat, Feb 18, 2023 at 12:59 PM Hendrik Leppkes <h.leppkes@gmail.com>
wrote:

> On Sat, Feb 18, 2023 at 6:50 PM Marth64 <marth64@proxyid.net> wrote:
> >
> > Signed-off-by: Marth64 <marth64@proxyid.net>
> > ---
> > - Missed adding the profiles to actual codec descriptor in ac3dec_float
> > - Formatting tidyness
> >
> >  libavcodec/ac3dec.c       |  3 +++
> >  libavcodec/ac3dec.h       |  1 +
> >  libavcodec/ac3dec_float.c |  2 ++
> >  libavcodec/avcodec.h      |  2 ++
> >  libavcodec/codec_desc.c   |  1 +
> >  libavcodec/eac3dec.c      | 11 ++++++++++-
> >  libavcodec/profiles.c     |  5 +++++
> >  libavcodec/profiles.h     |  1 +
> >  8 files changed, 25 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
> > index 0b120e6140..b5f4b166d3 100644
> > --- a/libavcodec/ac3dec.c
> > +++ b/libavcodec/ac3dec.c
> > @@ -1714,6 +1714,9 @@ skip:
> >      if (!err) {
> >          avctx->sample_rate = s->sample_rate;
> >          avctx->bit_rate    = s->bit_rate + s->prev_bit_rate;
> > +
> > +        if (s->eac3_extension_type_a == 1)
> > +            avctx->profile = s->eac3_extension_type_a == 1 ?
> FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;
> >      }
>
> You have to leave out the if(..) for this to make sense. :)
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
  2023-02-18 19:43 ` Marth64
@ 2023-03-01 10:14   ` Hendrik Leppkes
  0 siblings, 0 replies; 8+ messages in thread
From: Hendrik Leppkes @ 2023-03-01 10:14 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Feb 18, 2023 at 8:43 PM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>

The entire set looks good to me now. If there are no further
objections or comments, I'll apply it in a day or two.

- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
       [not found] <306728>
@ 2023-02-18 19:43 ` Marth64
  2023-03-01 10:14   ` Hendrik Leppkes
  0 siblings, 1 reply; 8+ messages in thread
From: Marth64 @ 2023-02-18 19:43 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marth64

Signed-off-by: Marth64 <marth64@proxyid.net>
---
- Fix if() statement oversight

 libavcodec/ac3dec.c       |  1 +
 libavcodec/ac3dec.h       |  1 +
 libavcodec/ac3dec_float.c |  2 ++
 libavcodec/avcodec.h      |  2 ++
 libavcodec/codec_desc.c   |  1 +
 libavcodec/eac3dec.c      | 11 ++++++++++-
 libavcodec/profiles.c     |  5 +++++
 libavcodec/profiles.h     |  1 +
 8 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..fc0cbeb493 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1714,6 +1714,7 @@ skip:
     if (!err) {
         avctx->sample_rate = s->sample_rate;
         avctx->bit_rate    = s->bit_rate + s->prev_bit_rate;
+        avctx->profile     = s->eac3_extension_type_a == 1 ? FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;
     }
 
     if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
     int eac3;                               ///< indicates if current frame is E-AC-3
     int eac3_frame_dependent_found;         ///< bitstream has E-AC-3 dependent frame(s)
     int eac3_subsbtreamid_found;            ///< bitstream has E-AC-3 additional substream(s)
+    int eac3_extension_type_a;              ///< bitstream has E-AC-3 extension type A enabled frame(s)
     int dolby_surround_mode;                ///< dolby surround mode                    (dsurmod)
     int dolby_surround_ex_mode;             ///< dolby surround ex mode                 (dsurexmod)
     int dolby_headphone_mode;               ///< dolby headphone mode                   (dheadphonmod)
diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c
index b8868d8ee1..39d3cbd282 100644
--- a/libavcodec/ac3dec_float.c
+++ b/libavcodec/ac3dec_float.c
@@ -33,6 +33,7 @@
 
 #include "ac3dec.h"
 #include "codec_internal.h"
+#include "profiles.h"
 #include "eac3dec.c"
 #include "ac3dec.c"
 
@@ -92,6 +93,7 @@ const FFCodec ff_eac3_decoder = {
     .p.sample_fmts  = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
     .p.priv_class   = &ac3_eac3_decoder_class,
+    .p.profiles     = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 39881a1d2b..0e85dd50a4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1591,6 +1591,8 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_DTS_HD_MA   60
 #define FF_PROFILE_DTS_EXPRESS 70
 
+#define FF_PROFILE_EAC3_DDP_ATMOS         30
+
 #define FF_PROFILE_MPEG2_422    0
 #define FF_PROFILE_MPEG2_HIGH   1
 #define FF_PROFILE_MPEG2_SS     2
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 199f62df15..4098d4f5a5 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
         .name      = "eac3",
         .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+        .profiles  = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
     },
     {
         .id        = AV_CODEC_ID_SIPR,
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
     if (get_bits1(gbc)) {
         int addbsil = get_bits(gbc, 6);
         for (i = 0; i < addbsil + 1; i++) {
-            skip_bits(gbc, 8); // skip additional bit stream info
+            if (i == 0) {
+                /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+                   which can be used to detect Atmos presence */
+                skip_bits(gbc, 7);
+                if (get_bits1(gbc)) {
+                    s->eac3_extension_type_a = 1;
+                }
+            } else {
+                skip_bits(gbc, 8); // skip additional bit stream info
+            }
         }
     }
 
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..343b08f363 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = {
     { FF_PROFILE_UNKNOWN },
 };
 
+const AVProfile ff_eac3_profiles[] = {
+  { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+  { FF_PROFILE_UNKNOWN },
+};
+
 const AVProfile ff_dnxhd_profiles[] = {
   { FF_PROFILE_DNXHD,      "DNXHD"},
   { FF_PROFILE_DNXHR_LB,   "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..6ebedbd03f 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,7 @@
 
 extern const AVProfile ff_aac_profiles[];
 extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
 extern const AVProfile ff_dnxhd_profiles[];
 extern const AVProfile ff_h264_profiles[];
 extern const AVProfile ff_hevc_profiles[];
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
  2023-02-18  1:14 ` Marth64
  2023-02-18 16:45   ` Hendrik Leppkes
@ 2023-02-18 16:46   ` Hendrik Leppkes
  1 sibling, 0 replies; 8+ messages in thread
From: Hendrik Leppkes @ 2023-02-18 16:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Feb 18, 2023 at 2:15 AM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---

Another thing I noticed, you should add the profiles to the eac3
decoder AVCodec in ac3_float.c
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
  2023-02-18  1:14 ` Marth64
@ 2023-02-18 16:45   ` Hendrik Leppkes
  2023-02-18 16:46   ` Hendrik Leppkes
  1 sibling, 0 replies; 8+ messages in thread
From: Hendrik Leppkes @ 2023-02-18 16:45 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Feb 18, 2023 at 2:15 AM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
>  libavcodec/ac3dec.c     |  3 +++
>  libavcodec/ac3dec.h     |  1 +
>  libavcodec/avcodec.h    |  2 ++
>  libavcodec/codec_desc.c |  1 +
>  libavcodec/eac3dec.c    | 11 ++++++++++-
>  libavcodec/profiles.c   |  5 +++++
>  libavcodec/profiles.h   |  1 +
>  7 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
> index 0b120e6140..8cede139b8 100644
> --- a/libavcodec/ac3dec.c
> +++ b/libavcodec/ac3dec.c
> @@ -1714,6 +1714,9 @@ skip:
>      if (!err) {
>          avctx->sample_rate = s->sample_rate;
>          avctx->bit_rate    = s->bit_rate + s->prev_bit_rate;
> +
> +        if (s->eac3_extension_type_a == 1)
> +            avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
>      }

This should probably be something like:
avctx->profile     = s->eac3_extension_type_a == 1 ?
FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;

This way the profile is properly reset when there is no extension (anymore).

>
>      if (!avctx->sample_rate) {
> diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
> index 138b462abb..0829f4b40d 100644
> --- a/libavcodec/ac3dec.h
> +++ b/libavcodec/ac3dec.h
> @@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
>      int eac3;                               ///< indicates if current frame is E-AC-3
>      int eac3_frame_dependent_found;         ///< bitstream has E-AC-3 dependent frame(s)
>      int eac3_subsbtreamid_found;            ///< bitstream has E-AC-3 additional substream(s)
> +    int eac3_extension_type_a;              ///< bitstream has E-AC-3 extension type A enabled frame(s)
>      int dolby_surround_mode;                ///< dolby surround mode                    (dsurmod)
>      int dolby_surround_ex_mode;             ///< dolby surround ex mode                 (dsurexmod)
>      int dolby_headphone_mode;               ///< dolby headphone mode                   (dheadphonmod)
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 39881a1d2b..0e85dd50a4 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1591,6 +1591,8 @@ typedef struct AVCodecContext {
>  #define FF_PROFILE_DTS_HD_MA   60
>  #define FF_PROFILE_DTS_EXPRESS 70
>
> +#define FF_PROFILE_EAC3_DDP_ATMOS         30
> +
>  #define FF_PROFILE_MPEG2_422    0
>  #define FF_PROFILE_MPEG2_HIGH   1
>  #define FF_PROFILE_MPEG2_SS     2
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 199f62df15..4098d4f5a5 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
>          .name      = "eac3",
>          .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
>          .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
> +        .profiles  = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
>      },
>      {
>          .id        = AV_CODEC_ID_SIPR,
> diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
> index deca51dd3d..5c71751a0c 100644
> --- a/libavcodec/eac3dec.c
> +++ b/libavcodec/eac3dec.c
> @@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
>      if (get_bits1(gbc)) {
>          int addbsil = get_bits(gbc, 6);
>          for (i = 0; i < addbsil + 1; i++) {
> -            skip_bits(gbc, 8); // skip additional bit stream info
> +            if (i == 0) {
> +                /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
> +                   which can be used to detect Atmos presence */
> +                skip_bits(gbc, 7);
> +                if (get_bits1(gbc)) {
> +                    s->eac3_extension_type_a = 1;
> +                }
> +            } else {
> +                skip_bits(gbc, 8); // skip additional bit stream info
> +            }
>          }
>      }
>
> diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
> index 7af7fbeb13..343b08f363 100644
> --- a/libavcodec/profiles.c
> +++ b/libavcodec/profiles.c
> @@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = {
>      { FF_PROFILE_UNKNOWN },
>  };
>
> +const AVProfile ff_eac3_profiles[] = {
> +  { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
> +  { FF_PROFILE_UNKNOWN },
> +};
> +
>  const AVProfile ff_dnxhd_profiles[] = {
>    { FF_PROFILE_DNXHD,      "DNXHD"},
>    { FF_PROFILE_DNXHR_LB,   "DNXHR LB"},
> diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
> index 41a19aa9ad..6ebedbd03f 100644
> --- a/libavcodec/profiles.h
> +++ b/libavcodec/profiles.h
> @@ -58,6 +58,7 @@
>
>  extern const AVProfile ff_aac_profiles[];
>  extern const AVProfile ff_dca_profiles[];
> +extern const AVProfile ff_eac3_profiles[];
>  extern const AVProfile ff_dnxhd_profiles[];
>  extern const AVProfile ff_h264_profiles[];
>  extern const AVProfile ff_hevc_profiles[];
> --
> 2.25.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
       [not found] <306450>
@ 2023-02-18  1:14 ` Marth64
  2023-02-18 16:45   ` Hendrik Leppkes
  2023-02-18 16:46   ` Hendrik Leppkes
  0 siblings, 2 replies; 8+ messages in thread
From: Marth64 @ 2023-02-18  1:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marth64

Signed-off-by: Marth64 <marth64@proxyid.net>
---
 libavcodec/ac3dec.c     |  3 +++
 libavcodec/ac3dec.h     |  1 +
 libavcodec/avcodec.h    |  2 ++
 libavcodec/codec_desc.c |  1 +
 libavcodec/eac3dec.c    | 11 ++++++++++-
 libavcodec/profiles.c   |  5 +++++
 libavcodec/profiles.h   |  1 +
 7 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..8cede139b8 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1714,6 +1714,9 @@ skip:
     if (!err) {
         avctx->sample_rate = s->sample_rate;
         avctx->bit_rate    = s->bit_rate + s->prev_bit_rate;
+
+        if (s->eac3_extension_type_a == 1)
+            avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
     }
 
     if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
     int eac3;                               ///< indicates if current frame is E-AC-3
     int eac3_frame_dependent_found;         ///< bitstream has E-AC-3 dependent frame(s)
     int eac3_subsbtreamid_found;            ///< bitstream has E-AC-3 additional substream(s)
+    int eac3_extension_type_a;              ///< bitstream has E-AC-3 extension type A enabled frame(s)
     int dolby_surround_mode;                ///< dolby surround mode                    (dsurmod)
     int dolby_surround_ex_mode;             ///< dolby surround ex mode                 (dsurexmod)
     int dolby_headphone_mode;               ///< dolby headphone mode                   (dheadphonmod)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 39881a1d2b..0e85dd50a4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1591,6 +1591,8 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_DTS_HD_MA   60
 #define FF_PROFILE_DTS_EXPRESS 70
 
+#define FF_PROFILE_EAC3_DDP_ATMOS         30
+
 #define FF_PROFILE_MPEG2_422    0
 #define FF_PROFILE_MPEG2_HIGH   1
 #define FF_PROFILE_MPEG2_SS     2
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 199f62df15..4098d4f5a5 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
         .name      = "eac3",
         .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+        .profiles  = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
     },
     {
         .id        = AV_CODEC_ID_SIPR,
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
     if (get_bits1(gbc)) {
         int addbsil = get_bits(gbc, 6);
         for (i = 0; i < addbsil + 1; i++) {
-            skip_bits(gbc, 8); // skip additional bit stream info
+            if (i == 0) {
+                /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+                   which can be used to detect Atmos presence */
+                skip_bits(gbc, 7);
+                if (get_bits1(gbc)) {
+                    s->eac3_extension_type_a = 1;
+                }
+            } else {
+                skip_bits(gbc, 8); // skip additional bit stream info
+            }
         }
     }
 
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..343b08f363 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = {
     { FF_PROFILE_UNKNOWN },
 };
 
+const AVProfile ff_eac3_profiles[] = {
+  { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+  { FF_PROFILE_UNKNOWN },
+};
+
 const AVProfile ff_dnxhd_profiles[] = {
   { FF_PROFILE_DNXHD,      "DNXHD"},
   { FF_PROFILE_DNXHR_LB,   "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..6ebedbd03f 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,7 @@
 
 extern const AVProfile ff_aac_profiles[];
 extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
 extern const AVProfile ff_dnxhd_profiles[];
 extern const AVProfile ff_h264_profiles[];
 extern const AVProfile ff_hevc_profiles[];
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-03-01 10:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <306722>
2023-02-18 17:49 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
2023-02-18 18:59   ` Hendrik Leppkes
2023-02-18 19:35     ` Marth64
     [not found] <306728>
2023-02-18 19:43 ` Marth64
2023-03-01 10:14   ` Hendrik Leppkes
     [not found] <306450>
2023-02-18  1:14 ` Marth64
2023-02-18 16:45   ` Hendrik Leppkes
2023-02-18 16:46   ` Hendrik Leppkes

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git