* [FFmpeg-devel] [PATCH v5 1/7] avcodec/ac3_parser{, _internal}: expose AC-3 bit_rate_code
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
@ 2022-06-30 6:42 ` Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 2/7] {configure, avformat/movenc}: enable AC-3 parser for movenc Jan Ekström
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 6:42 UTC (permalink / raw)
To: ffmpeg-devel
From: Jan Ekström <jan.ekstrom@24i.com>
Required by MP4's AC3SpecificBox and MPEG-TS AC-3 audio_descriptor,
of which the former is implemented in our MP4 writer.
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
libavcodec/ac3_parser.c | 5 ++++-
libavcodec/ac3_parser_internal.h | 1 +
libavcodec/version.h | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 119b1598c5..4f154bb7c4 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -70,6 +70,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
return AAC_AC3_PARSE_ERROR_BSID;
hdr->num_blocks = 6;
+ hdr->ac3_bit_rate_code = -1;
/* set default mix levels */
hdr->center_mix_level = 5; // -4.5dB
@@ -89,6 +90,8 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
if(frame_size_code > 37)
return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
+ hdr->ac3_bit_rate_code = (frame_size_code >> 1);
+
skip_bits(gbc, 5); // skip bsid, already got it
hdr->bitstream_mode = get_bits(gbc, 3);
@@ -106,7 +109,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8;
hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift;
- hdr->bit_rate = (ff_ac3_bitrate_tab[frame_size_code>>1] * 1000) >> hdr->sr_shift;
+ hdr->bit_rate = (ff_ac3_bitrate_tab[hdr->ac3_bit_rate_code] * 1000) >> hdr->sr_shift;
hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
hdr->frame_size = ff_ac3_frame_size_tab[frame_size_code][hdr->sr_code] * 2;
hdr->frame_type = EAC3_FRAME_TYPE_AC3_CONVERT; //EAC3_FRAME_TYPE_INDEPENDENT;
diff --git a/libavcodec/ac3_parser_internal.h b/libavcodec/ac3_parser_internal.h
index dd57dc95a6..bd4e1bbffb 100644
--- a/libavcodec/ac3_parser_internal.h
+++ b/libavcodec/ac3_parser_internal.h
@@ -60,6 +60,7 @@ typedef struct AC3HeaderInfo {
uint8_t channels;
uint16_t frame_size;
uint64_t channel_layout;
+ int8_t ac3_bit_rate_code;
/** @} */
} AC3HeaderInfo;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 0ef6c991f3..1008fead27 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 34
+#define LIBAVCODEC_VERSION_MINOR 35
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.36.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] 9+ messages in thread
* [FFmpeg-devel] [PATCH v5 2/7] {configure, avformat/movenc}: enable AC-3 parser for movenc
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 1/7] avcodec/ac3_parser{, _internal}: expose AC-3 bit_rate_code Jan Ekström
@ 2022-06-30 6:42 ` Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 3/7] avformat/movenc: enable handle_eac3 to handle AC-3 tracks Jan Ekström
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 6:42 UTC (permalink / raw)
To: ffmpeg-devel
From: Jan Ekström <jan.ekstrom@24i.com>
This simplifies the code to no longer have #ifs in a manner which
does not require handling avpriv_ac3_parse_header returning ENOSYS.
As an existing example, the MPEG-TS muxer already requires the AC-3
parser, and in order to fix existing issues with the current AC-3
movenc code, switching to use the AC-3 parser is required, so this
is an enabling change for that.
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
configure | 2 +-
libavformat/movenc.c | 4 ----
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/configure b/configure
index 0de9b2abcb..fea512e8ef 100755
--- a/configure
+++ b/configure
@@ -3444,7 +3444,7 @@ mlp_demuxer_select="mlp_parser"
mmf_muxer_select="riffenc"
mov_demuxer_select="iso_media riffdec"
mov_demuxer_suggest="zlib"
-mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf aac_adtstoasc_bsf"
+mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf aac_adtstoasc_bsf ac3_parser"
mp3_demuxer_select="mpegaudio_parser"
mp3_muxer_select="mpegaudioheader"
mp4_muxer_select="mov_muxer"
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 106b5a6807..b799491fd4 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -408,7 +408,6 @@ struct eac3_info {
} substream[1]; /* TODO: support 8 independent substreams */
};
-#if CONFIG_AC3_PARSER
static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
{
AC3HeaderInfo *hdr = NULL;
@@ -549,7 +548,6 @@ end:
return ret;
}
-#endif
static int mov_write_eac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
@@ -6093,7 +6091,6 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
-#if CONFIG_AC3_PARSER
} else if (par->codec_id == AV_CODEC_ID_EAC3) {
size = handle_eac3(mov, pkt, trk);
if (size < 0)
@@ -6101,7 +6098,6 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
else if (!size)
goto end;
avio_write(pb, pkt->data, size);
-#endif
} else if (par->codec_id == AV_CODEC_ID_EIA_608) {
size = 8;
--
2.36.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] 9+ messages in thread
* [FFmpeg-devel] [PATCH v5 3/7] avformat/movenc: enable handle_eac3 to handle AC-3 tracks
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 1/7] avcodec/ac3_parser{, _internal}: expose AC-3 bit_rate_code Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 2/7] {configure, avformat/movenc}: enable AC-3 parser for movenc Jan Ekström
@ 2022-06-30 6:42 ` Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 4/7] avformat/movenc: move eac3_info definition so that it can be used for AC-3 Jan Ekström
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 6:42 UTC (permalink / raw)
To: ffmpeg-devel
From: Jan Ekström <jan.ekstrom@24i.com>
Add the AC-3 frame type, as well as early exit from additional packet
parsing in case of AC-3, as only a single packet is required to get
the required information.
Additionally, expose ac3_bit_rate_code via the eac3_info struct as
it is required for AC3SpecificBox.
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
libavformat/movenc.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b799491fd4..8316fd9a45 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -384,6 +384,7 @@ struct eac3_info {
/* Layout of the EC3SpecificBox */
/* maximum bitrate */
uint16_t data_rate;
+ int8_t ac3_bit_rate_code;
/* number of independent substreams */
uint8_t num_ind_sub;
struct {
@@ -414,8 +415,12 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
struct eac3_info *info;
int num_blocks, ret;
- if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info))))
- return AVERROR(ENOMEM);
+ if (!track->eac3_priv) {
+ if (!(track->eac3_priv = av_mallocz(sizeof(*info))))
+ return AVERROR(ENOMEM);
+
+ ((struct eac3_info *)track->eac3_priv)->ac3_bit_rate_code = -1;
+ }
info = track->eac3_priv;
if (!info->pkt && !(info->pkt = av_packet_alloc()))
@@ -432,6 +437,8 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
}
info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);
+ info->ac3_bit_rate_code = FFMAX(info->ac3_bit_rate_code,
+ hdr->ac3_bit_rate_code);
num_blocks = hdr->num_blocks;
if (!info->ec3_done) {
@@ -443,7 +450,8 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
/* this should always be the case, given that our AC-3 parser
* concatenates dependent frames to their independent parent */
- if (hdr->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
+ if (hdr->frame_type == EAC3_FRAME_TYPE_INDEPENDENT ||
+ hdr->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT) {
/* substream ids must be incremental */
if (hdr->substreamid > info->num_ind_sub + 1) {
ret = AVERROR(EINVAL);
@@ -475,6 +483,14 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
info->substream[hdr->substreamid].acmod = hdr->channel_mode;
info->substream[hdr->substreamid].lfeon = hdr->lfe_on;
+ if (track->par->codec_id == AV_CODEC_ID_AC3) {
+ // with AC-3 we only require the information of a single packet,
+ // so we can finish as soon as the basic values of the bit stream
+ // have been set to the track's informational structure.
+ info->ec3_done = 1;
+ goto concatenate;
+ }
+
/* Parse dependent substream(s), if any */
if (pkt->size != hdr->frame_size) {
int cumul_size = hdr->frame_size;
--
2.36.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] 9+ messages in thread
* [FFmpeg-devel] [PATCH v5 4/7] avformat/movenc: move eac3_info definition so that it can be used for AC-3
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
` (2 preceding siblings ...)
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 3/7] avformat/movenc: enable handle_eac3 to handle AC-3 tracks Jan Ekström
@ 2022-06-30 6:42 ` Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 5/7] avformat/movenc: utilize existing AC-3 parsing workflow " Jan Ekström
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 6:42 UTC (permalink / raw)
To: ffmpeg-devel
From: Jan Ekström <jan.ekstrom@24i.com>
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
libavformat/movenc.c | 66 ++++++++++++++++++++++----------------------
1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8316fd9a45..b9e3f1a63e 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -328,6 +328,39 @@ static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track)
return 0x11;
}
+struct eac3_info {
+ AVPacket *pkt;
+ uint8_t ec3_done;
+ uint8_t num_blocks;
+
+ /* Layout of the EC3SpecificBox */
+ /* maximum bitrate */
+ uint16_t data_rate;
+ int8_t ac3_bit_rate_code;
+ /* number of independent substreams */
+ uint8_t num_ind_sub;
+ struct {
+ /* sample rate code (see ff_ac3_sample_rate_tab) 2 bits */
+ uint8_t fscod;
+ /* bit stream identification 5 bits */
+ uint8_t bsid;
+ /* one bit reserved */
+ /* audio service mixing (not supported yet) 1 bit */
+ /* bit stream mode 3 bits */
+ uint8_t bsmod;
+ /* audio coding mode 3 bits */
+ uint8_t acmod;
+ /* sub woofer on 1 bit */
+ uint8_t lfeon;
+ /* 3 bits reserved */
+ /* number of dependent substreams associated with this substream 4 bits */
+ uint8_t num_dep_sub;
+ /* channel locations of the dependent substream(s), if any, 9 bits */
+ uint16_t chan_loc;
+ /* if there is no dependent substream, then one bit reserved instead */
+ } substream[1]; /* TODO: support 8 independent substreams */
+};
+
static int mov_write_ac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
GetBitContext gbc;
@@ -376,39 +409,6 @@ static int mov_write_ac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *trac
return 11;
}
-struct eac3_info {
- AVPacket *pkt;
- uint8_t ec3_done;
- uint8_t num_blocks;
-
- /* Layout of the EC3SpecificBox */
- /* maximum bitrate */
- uint16_t data_rate;
- int8_t ac3_bit_rate_code;
- /* number of independent substreams */
- uint8_t num_ind_sub;
- struct {
- /* sample rate code (see ff_ac3_sample_rate_tab) 2 bits */
- uint8_t fscod;
- /* bit stream identification 5 bits */
- uint8_t bsid;
- /* one bit reserved */
- /* audio service mixing (not supported yet) 1 bit */
- /* bit stream mode 3 bits */
- uint8_t bsmod;
- /* audio coding mode 3 bits */
- uint8_t acmod;
- /* sub woofer on 1 bit */
- uint8_t lfeon;
- /* 3 bits reserved */
- /* number of dependent substreams associated with this substream 4 bits */
- uint8_t num_dep_sub;
- /* channel locations of the dependent substream(s), if any, 9 bits */
- uint16_t chan_loc;
- /* if there is no dependent substream, then one bit reserved instead */
- } substream[1]; /* TODO: support 8 independent substreams */
-};
-
static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
{
AC3HeaderInfo *hdr = NULL;
--
2.36.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] 9+ messages in thread
* [FFmpeg-devel] [PATCH v5 5/7] avformat/movenc: utilize existing AC-3 parsing workflow for AC-3
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
` (3 preceding siblings ...)
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 4/7] avformat/movenc: move eac3_info definition so that it can be used for AC-3 Jan Ekström
@ 2022-06-30 6:42 ` Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 6/7] avformat/movenc: handle OOM situations when parsing AC-3 headers Jan Ekström
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 6:42 UTC (permalink / raw)
To: ffmpeg-devel
From: Jan Ekström <jan.ekstrom@24i.com>
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
libavformat/movenc.c | 46 +++++++++++++++++---------------------------
1 file changed, 18 insertions(+), 28 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b9e3f1a63e..382c2f2e75 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -363,44 +363,34 @@ struct eac3_info {
static int mov_write_ac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
- GetBitContext gbc;
+ struct eac3_info *info = track->eac3_priv;
PutBitContext pbc;
uint8_t buf[3];
- int fscod, bsid, bsmod, acmod, lfeon, frmsizecod;
- if (track->vos_len < 7) {
+ if (!info || !info->ec3_done) {
av_log(s, AV_LOG_ERROR,
"Cannot write moov atom before AC3 packets."
" Set the delay_moov flag to fix this.\n");
return AVERROR(EINVAL);
}
+ if (info->ac3_bit_rate_code < 0) {
+ av_log(s, AV_LOG_ERROR,
+ "No valid AC3 bit rate code for data rate of %d!\n",
+ info->data_rate);
+ return AVERROR(EINVAL);
+ }
+
avio_wb32(pb, 11);
ffio_wfourcc(pb, "dac3");
- init_get_bits(&gbc, track->vos_data + 4, (track->vos_len - 4) * 8);
- fscod = get_bits(&gbc, 2);
- frmsizecod = get_bits(&gbc, 6);
- bsid = get_bits(&gbc, 5);
- bsmod = get_bits(&gbc, 3);
- acmod = get_bits(&gbc, 3);
- if (acmod == 2) {
- skip_bits(&gbc, 2); // dsurmod
- } else {
- if ((acmod & 1) && acmod != 1)
- skip_bits(&gbc, 2); // cmixlev
- if (acmod & 4)
- skip_bits(&gbc, 2); // surmixlev
- }
- lfeon = get_bits1(&gbc);
-
init_put_bits(&pbc, buf, sizeof(buf));
- put_bits(&pbc, 2, fscod);
- put_bits(&pbc, 5, bsid);
- put_bits(&pbc, 3, bsmod);
- put_bits(&pbc, 3, acmod);
- put_bits(&pbc, 1, lfeon);
- put_bits(&pbc, 5, frmsizecod >> 1); // bit_rate_code
+ put_bits(&pbc, 2, info->substream[0].fscod);
+ put_bits(&pbc, 5, info->substream[0].bsid);
+ put_bits(&pbc, 3, info->substream[0].bsmod);
+ put_bits(&pbc, 3, info->substream[0].acmod);
+ put_bits(&pbc, 1, info->substream[0].lfeon);
+ put_bits(&pbc, 5, info->ac3_bit_rate_code); // bit_rate_code
put_bits(&pbc, 5, 0); // reserved
flush_put_bits(&pbc);
@@ -6029,8 +6019,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
if ((par->codec_id == AV_CODEC_ID_DNXHD ||
par->codec_id == AV_CODEC_ID_H264 ||
par->codec_id == AV_CODEC_ID_HEVC ||
- par->codec_id == AV_CODEC_ID_TRUEHD ||
- par->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len &&
+ par->codec_id == AV_CODEC_ID_TRUEHD) && !trk->vos_len &&
!TAG_IS_AVCI(trk->tag)) {
/* copy frame to create needed atoms */
trk->vos_len = size;
@@ -6107,7 +6096,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
- } else if (par->codec_id == AV_CODEC_ID_EAC3) {
+ } else if (par->codec_id == AV_CODEC_ID_EAC3 ||
+ par->codec_id == AV_CODEC_ID_AC3) {
size = handle_eac3(mov, pkt, trk);
if (size < 0)
return size;
--
2.36.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] 9+ messages in thread
* [FFmpeg-devel] [PATCH v5 6/7] avformat/movenc: handle OOM situations when parsing AC-3 headers
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
` (4 preceding siblings ...)
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 5/7] avformat/movenc: utilize existing AC-3 parsing workflow " Jan Ekström
@ 2022-06-30 6:42 ` Jan Ekström
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 7/7] avformat/movenc: limit ISOBMFF AC-3 mapping to bsids <=8 Jan Ekström
2022-06-30 13:18 ` [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 6:42 UTC (permalink / raw)
To: ffmpeg-devel
From: Jan Ekström <jan.ekstrom@24i.com>
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
libavformat/movenc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 382c2f2e75..022fab675e 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -416,7 +416,10 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
if (!info->pkt && !(info->pkt = av_packet_alloc()))
return AVERROR(ENOMEM);
- if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0) {
+ if ((ret = avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0)) {
+ if (ret == AVERROR(ENOMEM))
+ goto end;
+
/* drop the packets until we see a good one */
if (!track->entry) {
av_log(mov->fc, AV_LOG_WARNING, "Dropping invalid packet from start of the stream\n");
--
2.36.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] 9+ messages in thread
* [FFmpeg-devel] [PATCH v5 7/7] avformat/movenc: limit ISOBMFF AC-3 mapping to bsids <=8
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
` (5 preceding siblings ...)
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 6/7] avformat/movenc: handle OOM situations when parsing AC-3 headers Jan Ekström
@ 2022-06-30 6:42 ` Jan Ekström
2022-06-30 13:18 ` [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 6:42 UTC (permalink / raw)
To: ffmpeg-devel
From: Jan Ekström <jan.ekstrom@24i.com>
This leaves out RealAudio DolbyNet, which utilizes bsids 9 and 10,
It is not clear whether the interpreted bit rate value (divided by
2 or 4 depending on the variant), or the original bit rate value
should be utilized to receive the bit_rate_code index.
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
libavformat/movenc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 022fab675e..3c605f6474 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -374,6 +374,14 @@ static int mov_write_ac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *trac
return AVERROR(EINVAL);
}
+ if (info->substream[0].bsid > 8) {
+ av_log(s, AV_LOG_ERROR,
+ "RealAudio AC-3/DolbyNet with bsid %d is not defined by the "
+ "ISOBMFF specification in ETSI TS 102 366!\n",
+ info->substream[0].bsid);
+ return AVERROR(EINVAL);
+ }
+
if (info->ac3_bit_rate_code < 0) {
av_log(s, AV_LOG_ERROR,
"No valid AC3 bit rate code for data rate of %d!\n",
--
2.36.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] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage
2022-06-30 6:42 [FFmpeg-devel] [PATCH v5 0/7] avformat/movenc: normalize on AC-3 parser usage Jan Ekström
` (6 preceding siblings ...)
2022-06-30 6:42 ` [FFmpeg-devel] [PATCH v5 7/7] avformat/movenc: limit ISOBMFF AC-3 mapping to bsids <=8 Jan Ekström
@ 2022-06-30 13:18 ` Jan Ekström
7 siblings, 0 replies; 9+ messages in thread
From: Jan Ekström @ 2022-06-30 13:18 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Jun 30, 2022 at 9:42 AM Jan Ekström <jeebjp@gmail.com> wrote:
>
> The simplified parsing currently in `mov_write_ac3_tag` trusts the content
> of the packets a bit too much (the AC-3 parser returns all data fed to it,
> including any possible data before the start code), while the existing E-AC-3
> logic does proper header validation by utilizing the (E-)AC-3 parser.
>
> Thus, normalize on AC-3 parser usage for both AC-3 and E-AC-3.
>
> Difference to v4:
> * Reverted to v1 base (extending the avpriv) as it was preferred in review.
> * Reutilized the ac3_bit_rate_code variable in the parser instead of doing
> `frame_size_code>>1` again.
> * Added avcodec minor bump as it seems like we're heading towards the end here.
>
> Jan
Applied series to master, with the following minor adjustment:
- } else if (par->codec_id == AV_CODEC_ID_EAC3 ||
- par->codec_id == AV_CODEC_ID_AC3) {
+ } else if (par->codec_id == AV_CODEC_ID_AC3 ||
+ par->codec_id == AV_CODEC_ID_EAC3) {
Thanks for the reviews.
Jan
_______________________________________________
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] 9+ messages in thread