mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-23 11:19:55 +00:00
编程规范修订
Signed-off-by: liushuai <cqliushuai@outlook.com>
This commit is contained in:
parent
a8372d8c94
commit
5413bfa369
@ -2,7 +2,7 @@
|
|||||||
* AV3A Parser
|
* AV3A Parser
|
||||||
*
|
*
|
||||||
* Copyright (c) 2024 Shuai Liu <cqliushuai@outlook.com>
|
* Copyright (c) 2024 Shuai Liu <cqliushuai@outlook.com>
|
||||||
*
|
*
|
||||||
* This file is part of FFmpeg.
|
* This file is part of FFmpeg.
|
||||||
*
|
*
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
* FFmpeg is free software; you can redistribute it and/or
|
||||||
@ -81,7 +81,7 @@ static int ff_read_av3a_header_parse(GetBitContext *gb, AATFHeaderInfo *hdf)
|
|||||||
if (hdf->coding_profile == AV3A_BASE_PROFILE) {
|
if (hdf->coding_profile == AV3A_BASE_PROFILE) {
|
||||||
hdf->content_type = AV3A_CHANNEL_BASED_TYPE;
|
hdf->content_type = AV3A_CHANNEL_BASED_TYPE;
|
||||||
hdf->channel_number_index = get_bits(gb, 7);
|
hdf->channel_number_index = get_bits(gb, 7);
|
||||||
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(hdf->channel_number_index < 0)) {
|
(hdf->channel_number_index < 0)) {
|
||||||
@ -107,7 +107,7 @@ static int ff_read_av3a_header_parse(GetBitContext *gb, AATFHeaderInfo *hdf)
|
|||||||
} else if (hdf->soundbed_type == 1) {
|
} else if (hdf->soundbed_type == 1) {
|
||||||
hdf->content_type = AV3A_CHANNEL_OBJECT_TYPE;
|
hdf->content_type = AV3A_CHANNEL_OBJECT_TYPE;
|
||||||
hdf->channel_number_index = get_bits(gb, 7);
|
hdf->channel_number_index = get_bits(gb, 7);
|
||||||
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(hdf->channel_number_index < 0)) {
|
(hdf->channel_number_index < 0)) {
|
||||||
|
@ -91,7 +91,7 @@ static int av3a_read_aatf_frame_header(AATFHeaderInfo *hdf, const uint8_t *buf)
|
|||||||
if (hdf->coding_profile == AV3A_BASE_PROFILE) {
|
if (hdf->coding_profile == AV3A_BASE_PROFILE) {
|
||||||
hdf->content_type = AV3A_CHANNEL_BASED_TYPE;
|
hdf->content_type = AV3A_CHANNEL_BASED_TYPE;
|
||||||
hdf->channel_number_index = get_bits(&gb, 7);
|
hdf->channel_number_index = get_bits(&gb, 7);
|
||||||
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(hdf->channel_number_index < 0)) {
|
(hdf->channel_number_index < 0)) {
|
||||||
@ -115,7 +115,7 @@ static int av3a_read_aatf_frame_header(AATFHeaderInfo *hdf, const uint8_t *buf)
|
|||||||
} else if (hdf->soundbed_type == 1) {
|
} else if (hdf->soundbed_type == 1) {
|
||||||
hdf->content_type = AV3A_CHANNEL_OBJECT_TYPE;
|
hdf->content_type = AV3A_CHANNEL_OBJECT_TYPE;
|
||||||
hdf->channel_number_index = get_bits(&gb, 7);
|
hdf->channel_number_index = get_bits(&gb, 7);
|
||||||
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((hdf->channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(hdf->channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(hdf->channel_number_index < 0)) {
|
(hdf->channel_number_index < 0)) {
|
||||||
@ -174,7 +174,7 @@ static int av3a_read_aatf_frame_header(AATFHeaderInfo *hdf, const uint8_t *buf)
|
|||||||
}
|
}
|
||||||
hdf->resolution = ff_av3a_sample_format_map_table[hdf->resolution_index].resolution;
|
hdf->resolution = ff_av3a_sample_format_map_table[hdf->resolution_index].resolution;
|
||||||
hdf->sample_format = ff_av3a_sample_format_map_table[hdf->resolution_index].sample_format;
|
hdf->sample_format = ff_av3a_sample_format_map_table[hdf->resolution_index].sample_format;
|
||||||
|
|
||||||
if (hdf->coding_profile != AV3A_OBJECT_METADATA_PROFILE) {
|
if (hdf->coding_profile != AV3A_OBJECT_METADATA_PROFILE) {
|
||||||
hdf->bitrate_index = get_bits(&gb, 4);
|
hdf->bitrate_index = get_bits(&gb, 4);
|
||||||
if ((hdf->bitrate_index >= AV3A_BITRATE_TABLE_SIZE) || (hdf->bitrate_index < 0)){
|
if ((hdf->bitrate_index >= AV3A_BITRATE_TABLE_SIZE) || (hdf->bitrate_index < 0)){
|
||||||
@ -207,6 +207,10 @@ static int av3a_get_packet_size(AVFormatContext *s)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!s->pb) {
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
read_bytes = avio_read(s->pb, header, AV3A_MAX_NBYTES_HEADER);
|
read_bytes = avio_read(s->pb, header, AV3A_MAX_NBYTES_HEADER);
|
||||||
if (read_bytes != AV3A_MAX_NBYTES_HEADER) {
|
if (read_bytes != AV3A_MAX_NBYTES_HEADER) {
|
||||||
return (read_bytes < 0) ? read_bytes : AVERROR_EOF;
|
return (read_bytes < 0) ? read_bytes : AVERROR_EOF;
|
||||||
@ -231,7 +235,7 @@ static int av3a_get_packet_size(AVFormatContext *s)
|
|||||||
|
|
||||||
if (coding_profile == AV3A_BASE_PROFILE) {
|
if (coding_profile == AV3A_BASE_PROFILE) {
|
||||||
channel_number_index = get_bits(&gb, 7);
|
channel_number_index = get_bits(&gb, 7);
|
||||||
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(channel_number_index < 0)) {
|
(channel_number_index < 0)) {
|
||||||
@ -254,7 +258,7 @@ static int av3a_get_packet_size(AVFormatContext *s)
|
|||||||
total_bitrate = ff_av3a_bitrate_map_table[CHANNEL_CONFIG_MONO].bitrate_table[bitrate_index_per_channel] * objects;
|
total_bitrate = ff_av3a_bitrate_map_table[CHANNEL_CONFIG_MONO].bitrate_table[bitrate_index_per_channel] * objects;
|
||||||
} else if (soundbed_type == 1) {
|
} else if (soundbed_type == 1) {
|
||||||
channel_number_index = get_bits(&gb, 7);
|
channel_number_index = get_bits(&gb, 7);
|
||||||
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(channel_number_index < 0)) {
|
(channel_number_index < 0)) {
|
||||||
@ -413,7 +417,7 @@ static int av3a_read_packet(AVFormatContext *s, AVPacket *pkt) {
|
|||||||
int read_bytes = 0;
|
int read_bytes = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (!s->streams[0]->codecpar) {
|
if (!s) {
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +437,15 @@ static int av3a_read_packet(AVFormatContext *s, AVPacket *pkt) {
|
|||||||
if ((ret = av_new_packet(pkt, packet_size)) < 0) {
|
if ((ret = av_new_packet(pkt, packet_size)) < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!s->streams[0]) {
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!s->streams[0]->codecpar) {
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
pkt->pos = pos;
|
pkt->pos = pos;
|
||||||
pkt->duration = s->streams[0]->codecpar->frame_size;
|
pkt->duration = s->streams[0]->codecpar->frame_size;
|
||||||
|
@ -7977,7 +7977,7 @@ static int mov_read_dca3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
if (content_type == AV3A_CHANNEL_BASED_TYPE) {
|
if (content_type == AV3A_CHANNEL_BASED_TYPE) {
|
||||||
channel_number_index = get_bits(&gb, 7);
|
channel_number_index = get_bits(&gb, 7);
|
||||||
reserved = get_bits(&gb, 1);
|
reserved = get_bits(&gb, 1);
|
||||||
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(channel_number_index < 0)) {
|
(channel_number_index < 0)) {
|
||||||
@ -7988,10 +7988,13 @@ static int mov_read_dca3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
number_objects = get_bits(&gb, 7);
|
number_objects = get_bits(&gb, 7);
|
||||||
reserved = get_bits(&gb, 1);
|
reserved = get_bits(&gb, 1);
|
||||||
nb_objects = number_objects;
|
nb_objects = number_objects;
|
||||||
|
if (nb_objects < 1) {
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
} else if (content_type == AV3A_CHANNEL_OBJECT_TYPE) {
|
} else if (content_type == AV3A_CHANNEL_OBJECT_TYPE) {
|
||||||
channel_number_index = get_bits(&gb, 7);
|
channel_number_index = get_bits(&gb, 7);
|
||||||
reserved = get_bits(&gb, 1);
|
reserved = get_bits(&gb, 1);
|
||||||
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
if ((channel_number_index >= CHANNEL_CONFIG_UNKNOWN) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_10_2) ||
|
||||||
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
(channel_number_index == CHANNEL_CONFIG_MC_22_2) ||
|
||||||
(channel_number_index < 0)) {
|
(channel_number_index < 0)) {
|
||||||
@ -8001,6 +8004,9 @@ static int mov_read_dca3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
reserved = get_bits(&gb, 1);
|
reserved = get_bits(&gb, 1);
|
||||||
nb_channels = ff_av3a_channels_map_table[channel_number_index].channels;
|
nb_channels = ff_av3a_channels_map_table[channel_number_index].channels;
|
||||||
nb_objects = number_objects;
|
nb_objects = number_objects;
|
||||||
|
if (nb_objects < 1) {
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
} else if (content_type == AV3A_AMBISONIC_TYPE) {
|
} else if (content_type == AV3A_AMBISONIC_TYPE) {
|
||||||
hoa_order = get_bits(&gb , 4);
|
hoa_order = get_bits(&gb , 4);
|
||||||
if ((hoa_order < AV3A_AMBISONIC_FIRST_ORDER) || (hoa_order > AV3A_AMBISONIC_THIRD_ORDER)) {
|
if ((hoa_order < AV3A_AMBISONIC_FIRST_ORDER) || (hoa_order > AV3A_AMBISONIC_THIRD_ORDER)) {
|
||||||
@ -8025,18 +8031,17 @@ static int mov_read_dca3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
if (content_type != AV3A_AMBISONIC_TYPE) {
|
if (content_type != AV3A_AMBISONIC_TYPE) {
|
||||||
st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_CUSTOM;
|
st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_CUSTOM;
|
||||||
st->codecpar->ch_layout.nb_channels = (nb_channels + nb_objects);
|
st->codecpar->ch_layout.nb_channels = (nb_channels + nb_objects);
|
||||||
st->codecpar->ch_layout.u.map = av_calloc(st->codecpar->ch_layout.nb_channels,
|
st->codecpar->ch_layout.u.map = av_calloc(st->codecpar->ch_layout.nb_channels, sizeof(AVChannelCustom));
|
||||||
sizeof(*st->codecpar->ch_layout.u.map));
|
|
||||||
if (!st->codecpar->ch_layout.u.map) {
|
if (!st->codecpar->ch_layout.u.map) {
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content_type != AV3A_OBJECT_BASED_TYPE) {
|
if (content_type != AV3A_OBJECT_BASED_TYPE) {
|
||||||
for(i = 0; i < nb_channels; i ++) {
|
for(i = 0; i < nb_channels; i ++) {
|
||||||
st->codecpar->ch_layout.u.map[i].id = ff_av3a_channels_map_table[channel_number_index].channel_layout[i];
|
st->codecpar->ch_layout.u.map[i].id = ff_av3a_channels_map_table[channel_number_index].channel_layout[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = nb_channels; i < st->codecpar->ch_layout.nb_channels; i++) {
|
for (i = nb_channels; i < st->codecpar->ch_layout.nb_channels; i++) {
|
||||||
st->codecpar->ch_layout.u.map[i].id = AV3A_CH_AUDIO_OBJECT;
|
st->codecpar->ch_layout.u.map[i].id = AV3A_CH_AUDIO_OBJECT;
|
||||||
}
|
}
|
||||||
|
@ -934,7 +934,6 @@ static int mov_write_dca3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra
|
|||||||
}
|
}
|
||||||
put_bits(&pb_dca3, 4, audio_codec_id);
|
put_bits(&pb_dca3, 4, audio_codec_id);
|
||||||
put_bits(&pb_dca3, 4, sampling_frequency_index);
|
put_bits(&pb_dca3, 4, sampling_frequency_index);
|
||||||
|
|
||||||
put_bits(&pb_dca3, 3, nn_type);
|
put_bits(&pb_dca3, 3, nn_type);
|
||||||
put_bits(&pb_dca3, 1, 0); /* reserved */
|
put_bits(&pb_dca3, 1, 0); /* reserved */
|
||||||
put_bits(&pb_dca3, 4, content_type);
|
put_bits(&pb_dca3, 4, content_type);
|
||||||
@ -1334,7 +1333,7 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
|
|||||||
#ifdef OHOS_AV3A_DEMUXER
|
#ifdef OHOS_AV3A_DEMUXER
|
||||||
track->par->codec_id == AV_CODEC_ID_OPUS ||
|
track->par->codec_id == AV_CODEC_ID_OPUS ||
|
||||||
track->par->codec_id == AV_CODEC_ID_AVS3DA
|
track->par->codec_id == AV_CODEC_ID_AVS3DA
|
||||||
#else
|
#else
|
||||||
track->par->codec_id == AV_CODEC_ID_OPUS
|
track->par->codec_id == AV_CODEC_ID_OPUS
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
@ -8360,7 +8359,7 @@ static const AVCodecTag codec_mp4_tags[] = {
|
|||||||
#ifdef OHOS_TIMED_META_TRACK
|
#ifdef OHOS_TIMED_META_TRACK
|
||||||
{ AV_CODEC_ID_FFMETADATA, MKTAG('c', 'd', 's', 'c') },
|
{ AV_CODEC_ID_FFMETADATA, MKTAG('c', 'd', 's', 'c') },
|
||||||
#endif
|
#endif
|
||||||
#ifdef OHOS_AV3A_DEMUXER
|
#ifdef
|
||||||
{ AV_CODEC_ID_AVS3DA, MKTAG('a', 'v', '3', 'a') },
|
{ AV_CODEC_ID_AVS3DA, MKTAG('a', 'v', '3', 'a') },
|
||||||
#endif
|
#endif
|
||||||
{ AV_CODEC_ID_NONE, 0 },
|
{ AV_CODEC_ID_NONE, 0 },
|
||||||
|
@ -447,7 +447,6 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return stream_type;
|
return stream_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user