[FFmpeg-devel] [PATCH 1/8] avformat/mpegts: add dvb ac3 descriptor metadata
Marton Balint
cus at passwd.hu
Wed Jul 22 20:44:06 EEST 2020
On Wed, 22 Jul 2020, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
>
> Below is one metadata information for the ts with dvb ac3 descriptor audio:
> ./ffmpeg -i ac3_desc.ts
> ...
> Stream #0:1[0x294]: Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), fltp, 448 kb/s
> Metadata:
> dvb.ac3_desc.component_type: 68
> dvb.ac3_desc.bsid: 6
> dvb.ac3_desc.mainid: 0
I don't think it is a good idea to use metadata for this. See how dolby
vision stores the descripor data, it is using side data and not metadata.
Also it might make sense to create a generic mpegts descriptor side data
type?
Regards.
Marton
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> libavformat/mpegts.c | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index c6fd3e1..1ed7eaf 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2073,15 +2073,33 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
> break;
> case 0x6a: /* ac-3_descriptor */
> {
> - int component_type_flag = get8(pp, desc_end) & (1 << 7);
> + uint8_t flags = get8(pp, desc_end);
> + uint8_t component_type_flag = flags & (1 << 7);
> + uint8_t bsid_flag = flags & (1 << 6);
> + uint8_t mainid_flag = flags & (1 << 5);
> + uint8_t asvc_flag = flags & (1 << 4);
> +
> if (component_type_flag) {
> - int component_type = get8(pp, desc_end);
> + uint8_t component_type = get8(pp, desc_end);
> int service_type_mask = 0x38; // 0b00111000
> int service_type = ((component_type & service_type_mask) >> 3);
> if (service_type == 0x02 /* 0b010 */) {
> st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
> av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track disposition for id %u: %u\n", st->id, st->disposition);
> }
> + av_dict_set_int(&st->metadata, "dvb.ac3_desc.component_type", component_type, 0);
> + }
> + if (bsid_flag) {
> + uint8_t bsid = get8(pp, desc_end);
> + av_dict_set_int(&st->metadata, "dvb.ac3_desc.bsid", bsid, 0);
> + }
> + if (mainid_flag) {
> + uint8_t mainid = get8(pp, desc_end);
> + av_dict_set_int(&st->metadata, "dvb.ac3_desc.mainid", mainid, 0);
> + }
> + if (asvc_flag) {
> + uint8_t asvc = get8(pp, desc_end);
> + av_dict_set_int(&st->metadata, "dvb.ac3_desc.asvc", asvc, 0);
> }
> }
> break;
> --
> 1.8.3.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list