编程规范修订

Signed-off-by: liushuai <cqliushuai@outlook.com>
This commit is contained in:
liushuai 2024-11-06 21:49:31 +08:00
parent a8372d8c94
commit 5413bfa369
5 changed files with 35 additions and 20 deletions

View File

@ -2,7 +2,7 @@
* AV3A Parser
*
* Copyright (c) 2024 Shuai Liu <cqliushuai@outlook.com>
*
*
* This file is part of FFmpeg.
*
* 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) {
hdf->content_type = AV3A_CHANNEL_BASED_TYPE;
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_22_2) ||
(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) {
hdf->content_type = AV3A_CHANNEL_OBJECT_TYPE;
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_22_2) ||
(hdf->channel_number_index < 0)) {

View File

@ -91,7 +91,7 @@ static int av3a_read_aatf_frame_header(AATFHeaderInfo *hdf, const uint8_t *buf)
if (hdf->coding_profile == AV3A_BASE_PROFILE) {
hdf->content_type = AV3A_CHANNEL_BASED_TYPE;
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_22_2) ||
(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) {
hdf->content_type = AV3A_CHANNEL_OBJECT_TYPE;
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_22_2) ||
(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->sample_format = ff_av3a_sample_format_map_table[hdf->resolution_index].sample_format;
if (hdf->coding_profile != AV3A_OBJECT_METADATA_PROFILE) {
hdf->bitrate_index = get_bits(&gb, 4);
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);
}
if (!s->pb) {
return AVERROR(ENOMEM);
}
read_bytes = avio_read(s->pb, header, AV3A_MAX_NBYTES_HEADER);
if (read_bytes != AV3A_MAX_NBYTES_HEADER) {
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) {
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_22_2) ||
(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;
} else if (soundbed_type == 1) {
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_22_2) ||
(channel_number_index < 0)) {
@ -413,7 +417,7 @@ static int av3a_read_packet(AVFormatContext *s, AVPacket *pkt) {
int read_bytes = 0;
int ret = 0;
if (!s->streams[0]->codecpar) {
if (!s) {
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) {
return ret;
}
if (!s->streams[0]) {
return AVERROR(ENOMEM);
}
if (!s->streams[0]->codecpar) {
return AVERROR(ENOMEM);
}
pkt->stream_index = 0;
pkt->pos = pos;
pkt->duration = s->streams[0]->codecpar->frame_size;

View File

@ -7977,7 +7977,7 @@ static int mov_read_dca3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (content_type == AV3A_CHANNEL_BASED_TYPE) {
channel_number_index = get_bits(&gb, 7);
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_22_2) ||
(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);
reserved = get_bits(&gb, 1);
nb_objects = number_objects;
if (nb_objects < 1) {
return AVERROR_INVALIDDATA;
}
} else if (content_type == AV3A_CHANNEL_OBJECT_TYPE) {
channel_number_index = get_bits(&gb, 7);
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_22_2) ||
(channel_number_index < 0)) {
@ -8001,6 +8004,9 @@ static int mov_read_dca3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
reserved = get_bits(&gb, 1);
nb_channels = ff_av3a_channels_map_table[channel_number_index].channels;
nb_objects = number_objects;
if (nb_objects < 1) {
return AVERROR_INVALIDDATA;
}
} else if (content_type == AV3A_AMBISONIC_TYPE) {
hoa_order = get_bits(&gb , 4);
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) {
st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_CUSTOM;
st->codecpar->ch_layout.nb_channels = (nb_channels + nb_objects);
st->codecpar->ch_layout.u.map = av_calloc(st->codecpar->ch_layout.nb_channels,
sizeof(*st->codecpar->ch_layout.u.map));
st->codecpar->ch_layout.u.map = av_calloc(st->codecpar->ch_layout.nb_channels, sizeof(AVChannelCustom));
if (!st->codecpar->ch_layout.u.map) {
return AVERROR(ENOMEM);
}
if (content_type != AV3A_OBJECT_BASED_TYPE) {
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];
}
}
for (i = nb_channels; i < st->codecpar->ch_layout.nb_channels; i++) {
st->codecpar->ch_layout.u.map[i].id = AV3A_CH_AUDIO_OBJECT;
}

View File

@ -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, sampling_frequency_index);
put_bits(&pb_dca3, 3, nn_type);
put_bits(&pb_dca3, 1, 0); /* reserved */
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
track->par->codec_id == AV_CODEC_ID_OPUS ||
track->par->codec_id == AV_CODEC_ID_AVS3DA
#else
#else
track->par->codec_id == AV_CODEC_ID_OPUS
#endif
) {
@ -8360,7 +8359,7 @@ static const AVCodecTag codec_mp4_tags[] = {
#ifdef OHOS_TIMED_META_TRACK
{ AV_CODEC_ID_FFMETADATA, MKTAG('c', 'd', 's', 'c') },
#endif
#ifdef OHOS_AV3A_DEMUXER
#ifdef
{ AV_CODEC_ID_AVS3DA, MKTAG('a', 'v', '3', 'a') },
#endif
{ AV_CODEC_ID_NONE, 0 },

View File

@ -447,7 +447,6 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
break;
}
return stream_type;
}