From patchwork Sat Oct 10 06:04:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Hards X-Patchwork-Id: 22829 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 71D9B449E2C for ; Sat, 10 Oct 2020 09:05:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 53CC168B9F3; Sat, 10 Oct 2020 09:05:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from cp1.nerdvana.net.au (cp1-new.nerdvana.net.au [113.212.99.70]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6149E68A562 for ; Sat, 10 Oct 2020 09:05:09 +0300 (EEST) Received: from ppp115-205.static.internode.on.net ([150.101.115.205]:45290 helo=minutae.fritz.box) by cp1.nerdvana.net.au with esmtpa (Exim 4.93) (envelope-from ) id 1kR808-000Bel-IV; Sat, 10 Oct 2020 17:05:04 +1100 From: Brad Hards To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Oct 2020 17:04:30 +1100 Message-Id: <20201010060430.25354-1-bradh@frogmouth.net> X-Mailer: git-send-email 2.17.1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cp1.nerdvana.net.au X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - frogmouth.net X-Get-Message-Sender-Via: cp1.nerdvana.net.au: authenticated_id: git@frogmouth.net X-Authenticated-Sender: cp1.nerdvana.net.au: git@frogmouth.net X-Source: X-Source-Args: X-Source-Dir: Subject: [FFmpeg-devel] [PATCH] lavf/mpeg: replace magic descriptor_tag values with defines X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Brad Hards MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This takes the used values from ISO/IEC 13818-1 Table 2-45 and adds them to the mpegts.h header. No functional changes. Signed-off-by: Brad Hards --- libavformat/mpegts.c | 16 ++++++++-------- libavformat/mpegts.h | 10 ++++++++++ libavformat/mpegtsenc.c | 6 +++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 432b1c3ea2..f750989629 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1804,12 +1804,12 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type mpegts_find_stream_type(st, desc_tag, DESC_types); switch (desc_tag) { - case 0x02: /* video stream descriptor */ + case VIDEO_STREAM_DESCRIPTOR: if (get8(pp, desc_end) & 0x1) { st->disposition |= AV_DISPOSITION_STILL_IMAGE; } break; - case 0x1E: /* SL descriptor */ + case SL_DESCRIPTOR: desc_es_id = get16(pp, desc_end); if (desc_es_id < 0) break; @@ -1832,7 +1832,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type mpegts_open_section_filter(ts, pid, m4sl_cb, ts, 1); } break; - case 0x1F: /* FMC descriptor */ + case FMC_DESCRIPTOR: if (get16(pp, desc_end) < 0) break; if (mp4_descr_count > 0 && @@ -1958,7 +1958,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type } } break; - case 0x0a: /* ISO 639 language descriptor */ + case ISO_639_LANGUAGE_DESCRIPTOR: for (i = 0; i + 4 <= desc_len; i += 4) { language[i + 0] = get8(pp, desc_end); language[i + 1] = get8(pp, desc_end); @@ -1984,7 +1984,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type av_dict_set(&st->metadata, "language", language, AV_DICT_DONT_OVERWRITE); } break; - case 0x05: /* registration descriptor */ + case REGISTRATION_DESCRIPTOR: st->codecpar->codec_tag = bytestream_get_le32(pp); av_log(fc, AV_LOG_TRACE, "reg_desc=%.4s\n", (char *)&st->codecpar->codec_tag); if (st->codecpar->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0) { @@ -1996,7 +1996,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type case 0x52: /* stream identifier descriptor */ st->stream_identifier = 1 + get8(pp, desc_end); break; - case 0x26: /* metadata descriptor */ + case METADATA_DESCRIPTOR: if (get16(pp, desc_end) == 0xFFFF) *pp += 4; if (get8(pp, desc_end) == 0xFF) { @@ -2338,13 +2338,13 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len // something else is broken, exit the program_descriptors_loop break; program_info_length -= len + 2; - if (tag == 0x1d) { // IOD descriptor + if (tag == IOD_DESCRIPTOR) { get8(&p, p_end); // scope get8(&p, p_end); // label len -= 2; mp4_read_iods(ts->stream, p, len, mp4_descr + mp4_descr_count, &mp4_descr_count, MAX_MP4_DESCR_COUNT); - } else if (tag == 0x05 && len >= 4) { // registration descriptor + } else if (tag == REGISTRATION_DESCRIPTOR && len >= 4) { prog_reg_desc = bytestream_get_le32(&p); len -= 4; } diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index d70b25d018..04874e0f42 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -144,6 +144,16 @@ #define STREAM_ID_METADATA_STREAM 0xfc #define STREAM_ID_EXTENDED_STREAM_ID 0xfd +/* ISO/IEC 13818-1 Table 2-45 */ +#define VIDEO_STREAM_DESCRIPTOR 0x02 +#define REGISTRATION_DESCRIPTOR 0x05 +#define ISO_639_LANGUAGE_DESCRIPTOR 0x0a +#define IOD_DESCRIPTOR 0x1d +#define SL_DESCRIPTOR 0x1e +#define FMC_DESCRIPTOR 0x1f +#define METADATA_DESCRIPTOR 0x26 +#define METADATA_STD_DESCRIPTOR 0x27 + typedef struct MpegTSContext MpegTSContext; MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s); diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 1687de74ad..afdaddad8e 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -275,7 +275,7 @@ static void putbuf(uint8_t **q_ptr, const uint8_t *buf, size_t len) static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag) { uint8_t *q = *q_ptr; - *q++ = 0x05; /* MPEG-2 registration descriptor*/ + *q++ = REGISTRATION_DESCRIPTOR; *q++ = 4; *q++ = tag; *q++ = tag >> 8; @@ -600,7 +600,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) char *next = lang->value; uint8_t *len_ptr; - *q++ = 0x0a; /* ISO 639 language descriptor */ + *q++ = ISO_639_LANGUAGE_DESCRIPTOR; len_ptr = q++; *len_ptr = 0; @@ -728,7 +728,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) put_registration_descriptor(&q, MKTAG('K', 'L', 'V', 'A')); } else if (codec_id == AV_CODEC_ID_TIMED_ID3) { const char *tag = "ID3 "; - *q++ = 0x26; /* metadata descriptor */ + *q++ = METADATA_DESCRIPTOR; *q++ = 13; put16(&q, 0xffff); /* metadata application format */ putbuf(&q, tag, strlen(tag));