History

cook: convert to new channel layout API

Anton Khirnov committed 13 years ago

Commit fa0c8a71 parent cdde7fe2 files · +16 −13Browse files

Unified · Split

2 files
  1. libavcodec/cook.c +14 −11
  2. libavcodec/cook_parser.c +2 −2
libavcodec/cook.c+14−11
@@ -1054,7 +1054,7 @@ static void dump_cook_context(COOKContext *q) · 1053 unmodified lines
10541054 PRINT("js_vlc_bits", q->subpacket[0].js_vlc_bits);
10551055 }
10561056 ff_dlog(q->avctx, "COOKContext\n");
1057− PRINT("nb_channels", q->avctx->channels);
1057+ PRINT("nb_channels", q->avctx->ch_layout.nb_channels);
10581058 PRINT("bit_rate", (int)q->avctx->bit_rate);
10591059 PRINT("sample_rate", q->avctx->sample_rate);
10601060 PRINT("samples_per_channel", q->subpacket[0].samples_per_channel);
@@ -1079,6 +1079,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 18 unmodified lines
10791079 unsigned int channel_mask = 0;
10801080 int samples_per_frame = 0;
10811081 int ret;
1082+ int channels = avctx->ch_layout.nb_channels;
1083+
10821084 q->avctx = avctx;
10831085
10841086 /* Take care of the codec specific extradata. */
@@ -1091,7 +1093,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 6 unmodified lines
10911093 bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
10921094
10931095 /* Take data from the AVCodecContext (RM container). */
1094− if (!avctx->channels) {
1096+ if (!channels) {
10951097 av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
10961098 return AVERROR_INVALIDDATA;
10971099 }
@@ -1123,7 +1125,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 25 unmodified lines
11231125 q->subpacket[s].js_vlc_bits = bytestream2_get_be16(&gb);
11241126
11251127 /* Initialize extradata related variables. */
1126− q->subpacket[s].samples_per_channel = samples_per_frame / avctx->channels;
1128+ q->subpacket[s].samples_per_channel = samples_per_frame / channels;
11271129 q->subpacket[s].bits_per_subpacket = avctx->block_align * 8;
11281130
11291131 /* Initialize default data states. */
@@ -1138,21 +1140,21 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 8 unmodified lines
11381140 q->subpacket[s].joint_stereo = 0;
11391141 switch (q->subpacket[s].cookversion) {
11401142 case MONO:
1141− if (avctx->channels != 1) {
1143+ if (channels != 1) {
11421144 avpriv_request_sample(avctx, "Container channels != 1");
11431145 return AVERROR_PATCHWELCOME;
11441146 }
11451147 av_log(avctx, AV_LOG_DEBUG, "MONO\n");
11461148 break;
11471149 case STEREO:
1148− if (avctx->channels != 1) {
1150+ if (channels != 1) {
11491151 q->subpacket[s].bits_per_subpdiv = 1;
11501152 q->subpacket[s].num_channels = 2;
11511153 }
11521154 av_log(avctx, AV_LOG_DEBUG, "STEREO\n");
11531155 break;
11541156 case JOINT_STEREO:
1155− if (avctx->channels != 2) {
1157+ if (channels != 2) {
11561158 avpriv_request_sample(avctx, "Container channels != 2");
11571159 return AVERROR_PATCHWELCOME;
11581160 }
@@ -1174,7 +1176,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 15 unmodified lines
11741176 av_log(avctx, AV_LOG_DEBUG, "MULTI_CHANNEL\n");
11751177 channel_mask |= q->subpacket[s].channel_mask = bytestream2_get_be32(&gb);
11761178
1177− if (av_get_channel_layout_nb_channels(q->subpacket[s].channel_mask) > 1) {
1179+ if (av_popcount64(q->subpacket[s].channel_mask) > 1) {
11781180 q->subpacket[s].total_subbands = q->subpacket[s].subbands +
11791181 q->subpacket[s].js_subband_start;
11801182 q->subpacket[s].joint_stereo = 1;
@@ -1233,8 +1235,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 52 unmodified lines
12331235 q->subpacket[s].gains2.now = q->subpacket[s].gain_3;
12341236 q->subpacket[s].gains2.previous = q->subpacket[s].gain_4;
12351237
1236− if (q->num_subpackets + q->subpacket[s].num_channels > q->avctx->channels) {
1237− av_log(avctx, AV_LOG_ERROR, "Too many subpackets %d for channels %d\n", q->num_subpackets, q->avctx->channels);
1238+ if (q->num_subpackets + q->subpacket[s].num_channels > channels) {
1239+ av_log(avctx, AV_LOG_ERROR, "Too many subpackets %d for channels %d\n", q->num_subpackets, channels);
12381240 return AVERROR_INVALIDDATA;
12391241 }
12401242
@@ -1282,10 +1284,11 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) · 41 unmodified lines
12821284 }
12831285
12841286 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
1287+ av_channel_layout_uninit(&avctx->ch_layout);
12851288 if (channel_mask)
1286− avctx->channel_layout = channel_mask;
1289+ av_channel_layout_from_mask(&avctx->ch_layout, channel_mask);
12871290 else
1288− avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
1291+ av_channel_layout_default(&avctx->ch_layout, channels);
12891292
12901293
12911294 dump_cook_context(q);
libavcodec/cook_parser.c+2−2
@@ -41,8 +41,8 @@ static int cook_parse(AVCodecParserContext *s1, AVCodecContext *avctx, · 40 unmodified lines
4141 CookParseContext *s = s1->priv_data;
4242
4343 if (!s->duration &&
44− avctx->extradata && avctx->extradata_size >= 8 && avctx->channels)
45− s->duration = AV_RB16(avctx->extradata + 4) / avctx->channels;
44+ avctx->extradata && avctx->extradata_size >= 8 && avctx->ch_layout.nb_channels)
45+ s->duration = AV_RB16(avctx->extradata + 4) / avctx->ch_layout.nb_channels;
4646
4747 s1->duration = s->duration;
4848

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t