Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-19 Thread lance . lmwang
On Thu, May 19, 2022 at 11:12:58AM +0200, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2022-05-11 15:30:37)
> > On Wed, May 11, 2022 at 02:00:10PM +0200, Anton Khirnov wrote:
> > > Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> > > > From: Limin Wang 
> > > > 
> > > > some samples include both A53 and SCTE20 data. Before the commit, both
> > > > of the will be exported, so the CC data will be repeated or garbarge
> > > 
> > > Why would it be garbage? That sounds like a bug.
> > > Why can't we just export both?
> > for A53/SCTE20/DVDCC are exprted by A53_CC side data and they're sharing
> > the same a53_buf_ref to store the data, so if stream contains CC wrapped
> > as ATSC A53 packets + the same data wrapped as SCTE-20 packets, the CC
> > data will repeated. We can consider to add a new side data type if 
> > necessary,
> > but it's preferable to export A53_CC even it's SCTE20, so we can't export
> > both by A53_CC still.
> 
> Does this apply to anything other than mpeg2? If not, it should be a
> codec-private option rather than a new global flag.

Yes, it's for mpeg2 only. At first, I think export_side_data option is 
proper place to use. But if export_side_data are considered to use for
global, then I'll consider to add a mpeg2-private option for it.

> 
> -- 
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-19 Thread Anton Khirnov
Quoting lance.lmw...@gmail.com (2022-05-11 15:30:37)
> On Wed, May 11, 2022 at 02:00:10PM +0200, Anton Khirnov wrote:
> > Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> > > From: Limin Wang 
> > > 
> > > some samples include both A53 and SCTE20 data. Before the commit, both
> > > of the will be exported, so the CC data will be repeated or garbarge
> > 
> > Why would it be garbage? That sounds like a bug.
> > Why can't we just export both?
> for A53/SCTE20/DVDCC are exprted by A53_CC side data and they're sharing
> the same a53_buf_ref to store the data, so if stream contains CC wrapped
> as ATSC A53 packets + the same data wrapped as SCTE-20 packets, the CC
> data will repeated. We can consider to add a new side data type if necessary,
> but it's preferable to export A53_CC even it's SCTE20, so we can't export
> both by A53_CC still.

Does this apply to anything other than mpeg2? If not, it should be a
codec-private option rather than a new global flag.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-11 Thread lance . lmwang
On Wed, May 11, 2022 at 02:00:10PM +0200, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> > From: Limin Wang 
> > 
> > some samples include both A53 and SCTE20 data. Before the commit, both
> > of the will be exported, so the CC data will be repeated or garbarge
> 
> Why would it be garbage? That sounds like a bug.
> Why can't we just export both?
for A53/SCTE20/DVDCC are exprted by A53_CC side data and they're sharing
the same a53_buf_ref to store the data, so if stream contains CC wrapped
as ATSC A53 packets + the same data wrapped as SCTE-20 packets, the CC
data will repeated. We can consider to add a new side data type if necessary,
but it's preferable to export A53_CC even it's SCTE20, so we can't export
both by A53_CC still.

related topic for it:
https://trac.ffmpeg.org/ticket/9724
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220427084949.73931-1-4ru...@gmail.com/
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20180306222512.20124-1-ffm...@tmm1.net/


> 
> -- 
> Anton Khirnov

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-11 Thread Anton Khirnov
Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> From: Limin Wang 
> 
> some samples include both A53 and SCTE20 data. Before the commit, both
> of the will be exported, so the CC data will be repeated or garbarge

Why would it be garbage? That sounds like a bug.
Why can't we just export both?

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-08 Thread lance . lmwang
From: Limin Wang 

some samples include both A53 and SCTE20 data. Before the commit, both
of the will be exported, so the CC data will be repeated or garbarge
as they're using the same frame side data. If you know your samples include
only one of them, You can export by +a53cc+scte20.

After the commit, the default will not export MPEG2 A53/SCTE20/DVD CC side data,
please export on demand.

Signed-off-by: Limin Wang 
---
 doc/codecs.texi| 10 ++
 libavcodec/avcodec.h   | 16 +++-
 libavcodec/mpeg12dec.c |  6 +++---
 libavcodec/options_table.h |  3 +++
 libavcodec/version.h   |  2 +-
 tests/fate/ffmpeg.mak  |  2 +-
 tests/fate/subtitles.mak   |  6 +++---
 7 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 5e10020900..4cced983b9 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -662,6 +662,16 @@ for codecs that support it. At present, those are H.264 
and VP9.
 @item film_grain
 Export film grain parameters through frame side data (see 
@code{AV_FRAME_DATA_FILM_GRAIN_PARAMS}).
 Supported at present by AV1 decoders.
+@item a53cc
+Export A53 CC through frame side data (see @code{AV_FRAME_DATA_A53_CC})
+for codecs that support it.
+@item scte20cc
+Export SCTE20 CC through frame side data (see @code{AV_FRAME_DATA_A53_CC})
+for codecs that support it.
+@item dvdcc
+Export DVD CC through frame side data (see @code{AV_FRAME_DATA_A53_CC})
+for codecs that support it.
+
 @end table
 
 @item threads @var{integer} (@emph{decoding/encoding,video})
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4dae23d06e..25fd4de2fe 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -360,7 +360,21 @@ typedef struct RcOverride{
  * Do not apply film grain, export it instead.
  */
 #define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)
-
+/**
+ * Decoding only.
+ * Export A53 CC through frame side data
+ */
+#define AV_CODEC_EXPORT_DATA_A53_CC (1 << 4)
+/**
+ * Decoding only.
+ * Export SCTE20 CC through frame side data
+ */
+#define AV_CODEC_EXPORT_DATA_SCTE20_CC (1 << 5)
+/**
+ * Decoding only.
+ * Export DVD CC through frame side data
+ */
+#define AV_CODEC_EXPORT_DATA_DVD_CC (1 << 6)
 /**
  * The decoder will keep a reference to the frame and may reuse it later.
  */
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index e9bde48f7a..032cb8f9b1 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2203,7 +2203,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 {
 Mpeg1Context *s1 = avctx->priv_data;
 
-if (buf_size >= 6 &&
+if (buf_size >= 6 && (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_A53_CC) &&
 p[0] == 'G' && p[1] == 'A' && p[2] == '9' && p[3] == '4' &&
 p[4] == 3 && (p[5] & 0x40)) {
 /* extract A53 Part 4 CC data */
@@ -2224,7 +2224,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 return 1;
-} else if (buf_size >= 2 &&
+} else if (buf_size >= 2 && (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_SCTE20_CC) &&
p[0] == 0x03 && (p[1]&0x7f) == 0x01) {
 /* extract SCTE-20 CC data */
 GetBitContext gb;
@@ -2269,7 +2269,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 return 1;
-} else if (buf_size >= 11 &&
+} else if (buf_size >= 11 && (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_DVD_CC) &&
p[0] == 'C' && p[1] == 'C' && p[2] == 0x01 && p[3] == 0xf8) {
 /* extract DVD CC data
  *
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index e72b4d12b6..3c6db07459 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -88,6 +88,9 @@ static const AVOption avcodec_options[] = {
 {"prft", "export Producer Reference Time through packet side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, 
A|V|S|E, "export_side_data"},
 {"venc_params", "export video encoding parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, 
INT_MAX, V|D, "export_side_data"},
 {"film_grain", "export film grain parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_FILM_GRAIN}, INT_MIN, INT_MAX, 
V|D, "export_side_data"},
+{"a53cc", "export A53 CC through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 
= AV_CODEC_EXPORT_DATA_A53_CC}, INT_MIN, INT_MAX, V|D, "export_side_data"},
+{"scte20cc", "export SCTE20 CC through frame side data", 0, AV_OPT_TYPE_CONST, 
{.i64 = AV_CODEC_EXPORT_DATA_SCTE20_CC}, INT_MIN, INT_MAX, V|D, 
"export_side_data"},
+{"dvdcc", "export DVD CC through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 
= AV_CODEC_EXPORT_DATA_DVD_CC}, INT_MIN, INT_MAX, V|D, "export_side_data"},
 {"time_base", NULL, OFFSET(time_base),