h->profile = get_bits(&s->gb,8);
h->level = get_bits(&s->gb,8);
skip_bits1(&s->gb); //progressive sequence
- width = get_bits(&s->gb,14);
- height = get_bits(&s->gb,14);
+
+ width = get_bits(&s->gb, 14);
+ height = get_bits(&s->gb, 14);
if ((s->width || s->height) && (s->width != width || s->height != height)) {
av_log_missing_feature(s, "Width/height changing in CAVS is", 0);
- return -1;
+ return AVERROR_PATCHWELCOME;
}
+ if (width <= 0 || height <= 0) {
+ av_log(s, AV_LOG_ERROR, "Dimensions invalid\n");
+ return AVERROR_INVALIDDATA;
+ }
s->width = width;
s->height = height;
+
skip_bits(&s->gb,2); //chroma format
skip_bits(&s->gb,3); //sample_precision
h->aspect_ratio = get_bits(&s->gb,4);
}
}
+ ret=0;
+
if (av_codec_is_decoder(avctx->codec)) {
+ if (!avctx->bit_rate)
+ avctx->bit_rate = get_bit_rate(avctx);
/* validate channel layout from the decoder */
- if (avctx->channel_layout &&
- av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
- av_log(avctx, AV_LOG_WARNING, "channel layout does not match number of channels\n");
- avctx->channel_layout = 0;
+ if (avctx->channel_layout) {
+ int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
+ if (!avctx->channels)
+ avctx->channels = channels;
+ else if (channels != avctx->channels) {
+ av_log(avctx, AV_LOG_WARNING,
+ "channel layout does not match number of channels\n");
+ avctx->channel_layout = 0;
+ }
}
}
end: