avformat/movenc: utilize existing AC-3 parsing workflow for AC-3
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
This commit is contained in:
parent
b6897e9c08
commit
3854c58d9e
@ -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_AC3 ||
|
||||
par->codec_id == AV_CODEC_ID_EAC3) {
|
||||
size = handle_eac3(mov, pkt, trk);
|
||||
if (size < 0)
|
||||
return size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user