* qatar/master: doc/APIchanges: add an entry for codec descriptors. vorbisenc: set AVCodecContext.bit_rate to 0 vorbisenc: fix quality parameter FATE: add ALAC encoding tests lpc: fix alignment of windowed samples for odd maximum LPC order alacenc: use s16p sample format as input alacenc: remove unneeded sample_fmt check alacenc: fix max_frame_size calculation for the final frame adpcm_swf: Use correct sample offsets when using trellis. rtmp: support strict rtmp servers mjpegdec: support AVRn interlaced x86: remove FASTDIV inline asm Conflicts: doc/APIchanges libavcodec/mjpegdec.c libavcodec/vorbisenc.c libavutil/x86/intmath.h
Showing the changes to libavcodec (6 of 10 files). Show all
Unified · Split
| @@ -616,10 +616,11 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 615 unmodified lines | |||
| 616 | 616 | ||
| 617 | if (avctx->trellis > 0) { | 617 | if (avctx->trellis > 0) { |
| 618 | FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error); | 618 | FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error); |
| 619 | adpcm_compress_trellis(avctx, samples + 2, buf, &c->status[0], n); | 619 | adpcm_compress_trellis(avctx, samples + avctx->channels, buf, |
| 620 | &c->status[0], n); | ||
| 620 | if (avctx->channels == 2) | 621 | if (avctx->channels == 2) |
| 621 | adpcm_compress_trellis(avctx, samples + 3, buf + n, | 622 | adpcm_compress_trellis(avctx, samples + avctx->channels + 1, |
| 622 | &c->status[1], n); | 623 | buf + n, &c->status[1], n); |
| 623 | for (i = 0; i < n; i++) { | 624 | for (i = 0; i < n; i++) { |
| 624 | put_bits(&pb, 4, buf[i]); | 625 | put_bits(&pb, 4, buf[i]); |
| 625 | if (avctx->channels == 2) | 626 | if (avctx->channels == 2) |
| @@ -78,17 +78,15 @@ typedef struct AlacEncodeContext { · 77 unmodified lines | |||
| 78 | } AlacEncodeContext; | 78 | } AlacEncodeContext; |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | static void init_sample_buffers(AlacEncodeContext *s, | 81 | static void init_sample_buffers(AlacEncodeContext *s, int16_t **input_samples) |
| 82 | const int16_t *input_samples) | ||
| 83 | { | 82 | { |
| 84 | int ch, i; | 83 | int ch, i; |
| 85 | 84 | ||
| 86 | for (ch = 0; ch < s->avctx->channels; ch++) { | 85 | for (ch = 0; ch < s->avctx->channels; ch++) { |
| 87 | const int16_t *sptr = input_samples + ch; | 86 | int32_t *bptr = s->sample_buf[ch]; |
| 88 | for (i = 0; i < s->frame_size; i++) { | 87 | const int16_t *sptr = input_samples[ch]; |
| 89 | s->sample_buf[ch][i] = *sptr; | 88 | for (i = 0; i < s->frame_size; i++) |
| 90 | sptr += s->avctx->channels; | 89 | bptr[i] = sptr[i]; |
| 91 | } | ||
| 92 | } | 90 | } |
| 93 | } | 91 | } |
| 94 | 92 | ||
| @@ -347,8 +345,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) · 252 unmodified lines | |||
| 347 | } | 345 | } |
| 348 | } | 346 | } |
| 349 | 347 | ||
| 350 | static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, | 348 | static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, int16_t **samples) |
| 351 | const int16_t *samples) | ||
| 352 | { | 349 | { |
| 353 | int i, j; | 350 | int i, j; |
| 354 | int prediction_type = 0; | 351 | int prediction_type = 0; |
| @@ -358,8 +355,10 @@ static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, · 3 unmodified lines | |||
| 358 | 355 | ||
| 359 | if (s->verbatim) { | 356 | if (s->verbatim) { |
| 360 | write_frame_header(s); | 357 | write_frame_header(s); |
| 361 | for (i = 0; i < s->frame_size * s->avctx->channels; i++) | 358 | /* samples are channel-interleaved in verbatim mode */ |
| 362 | put_sbits(pb, 16, *samples++); | 359 | for (i = 0; i < s->frame_size; i++) |
| 360 | for (j = 0; j < s->avctx->channels; j++) | ||
| 361 | put_sbits(pb, 16, samples[j][i]); | ||
| 363 | } else { | 362 | } else { |
| 364 | init_sample_buffers(s, samples); | 363 | init_sample_buffers(s, samples); |
| 365 | write_frame_header(s); | 364 | write_frame_header(s); |
| @@ -426,11 +425,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 60 unmodified lines | |||
| 426 | 425 | ||
| 427 | avctx->frame_size = s->frame_size = DEFAULT_FRAME_SIZE; | 426 | avctx->frame_size = s->frame_size = DEFAULT_FRAME_SIZE; |
| 428 | 427 | ||
| 429 | if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) { | ||
| 430 | av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n"); | ||
| 431 | return -1; | ||
| 432 | } | ||
| 433 | |||
| 434 | /* TODO: Correctly implement multi-channel ALAC. | 428 | /* TODO: Correctly implement multi-channel ALAC. |
| 435 | It is similar to multi-channel AAC, in that it has a series of | 429 | It is similar to multi-channel AAC, in that it has a series of |
| 436 | single-channel (SCE), channel-pair (CPE), and LFE elements. */ | 430 | single-channel (SCE), channel-pair (CPE), and LFE elements. */ |
| @@ -542,11 +536,11 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 105 unmodified lines | |||
| 542 | { | 536 | { |
| 543 | AlacEncodeContext *s = avctx->priv_data; | 537 | AlacEncodeContext *s = avctx->priv_data; |
| 544 | int out_bytes, max_frame_size, ret; | 538 | int out_bytes, max_frame_size, ret; |
| 545 | const int16_t *samples = (const int16_t *)frame->data[0]; | 539 | int16_t **samples = (int16_t **)frame->extended_data; |
| 546 | 540 | ||
| 547 | s->frame_size = frame->nb_samples; | 541 | s->frame_size = frame->nb_samples; |
| 548 | 542 | ||
| 549 | if (avctx->frame_size < DEFAULT_FRAME_SIZE) | 543 | if (frame->nb_samples < DEFAULT_FRAME_SIZE) |
| 550 | max_frame_size = get_max_frame_size(s->frame_size, avctx->channels, | 544 | max_frame_size = get_max_frame_size(s->frame_size, avctx->channels, |
| 551 | DEFAULT_SAMPLE_SIZE); | 545 | DEFAULT_SAMPLE_SIZE); |
| 552 | else | 546 | else |
| @@ -580,7 +574,7 @@ AVCodec ff_alac_encoder = { · 27 unmodified lines | |||
| 580 | .encode2 = alac_encode_frame, | 574 | .encode2 = alac_encode_frame, |
| 581 | .close = alac_encode_close, | 575 | .close = alac_encode_close, |
| 582 | .capabilities = CODEC_CAP_SMALL_LAST_FRAME, | 576 | .capabilities = CODEC_CAP_SMALL_LAST_FRAME, |
| 583 | .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, | 577 | .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P, |
| 584 | AV_SAMPLE_FMT_NONE }, | 578 | AV_SAMPLE_FMT_NONE }, |
| 585 | .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), | 579 | .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), |
| 586 | }; | 580 | }; |
| @@ -179,11 +179,9 @@ int ff_lpc_calc_coefs(LPCContext *s, · 178 unmodified lines | |||
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | if (lpc_type == FF_LPC_TYPE_LEVINSON) { | 181 | if (lpc_type == FF_LPC_TYPE_LEVINSON) { |
| 182 | double *windowed_samples = s->windowed_samples + max_order; | 182 | s->lpc_apply_welch_window(samples, blocksize, s->windowed_samples); |
| 183 | 183 | ||
| 184 | s->lpc_apply_welch_window(samples, blocksize, windowed_samples); | 184 | s->lpc_compute_autocorr(s->windowed_samples, blocksize, max_order, autoc); |
| 185 | |||
| 186 | s->lpc_compute_autocorr(windowed_samples, blocksize, max_order, autoc); | ||
| 187 | 185 | ||
| 188 | compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1); | 186 | compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1); |
| 189 | 187 | ||
| @@ -252,10 +250,11 @@ av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, · 62 unmodified lines | |||
| 252 | s->lpc_type = lpc_type; | 250 | s->lpc_type = lpc_type; |
| 253 | 251 | ||
| 254 | if (lpc_type == FF_LPC_TYPE_LEVINSON) { | 252 | if (lpc_type == FF_LPC_TYPE_LEVINSON) { |
| 255 | s->windowed_samples = av_mallocz((blocksize + max_order + 2) * | 253 | s->windowed_buffer = av_mallocz((blocksize + 2 + FFALIGN(max_order, 4)) * |
| 256 | sizeof(*s->windowed_samples)); | 254 | sizeof(*s->windowed_samples)); |
| 257 | if (!s->windowed_samples) | 255 | if (!s->windowed_buffer) |
| 258 | return AVERROR(ENOMEM); | 256 | return AVERROR(ENOMEM); |
| 257 | s->windowed_samples = s->windowed_buffer + FFALIGN(max_order, 4); | ||
| 259 | } else { | 258 | } else { |
| 260 | s->windowed_samples = NULL; | 259 | s->windowed_samples = NULL; |
| 261 | } | 260 | } |
| @@ -271,5 +270,5 @@ av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, · 9 unmodified lines | |||
| 271 | 270 | ||
| 272 | av_cold void ff_lpc_end(LPCContext *s) | 271 | av_cold void ff_lpc_end(LPCContext *s) |
| 273 | { | 272 | { |
| 274 | av_freep(&s->windowed_samples); | 273 | av_freep(&s->windowed_buffer); |
| 275 | } | 274 | } |
| @@ -51,6 +51,7 @@ typedef struct LPCContext { · 50 unmodified lines | |||
| 51 | int blocksize; | 51 | int blocksize; |
| 52 | int max_order; | 52 | int max_order; |
| 53 | enum FFLPCType lpc_type; | 53 | enum FFLPCType lpc_type; |
| 54 | double *windowed_buffer; | ||
| 54 | double *windowed_samples; | 55 | double *windowed_samples; |
| 55 | 56 | ||
| 56 | /** | 57 | /** |
| @@ -1235,6 +1235,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, · 1234 unmodified lines | |||
| 1235 | /* mjpeg-b can have padding bytes between sos and image data, skip them */ | 1235 | /* mjpeg-b can have padding bytes between sos and image data, skip them */ |
| 1236 | for (i = s->mjpb_skiptosod; i > 0; i--) | 1236 | for (i = s->mjpb_skiptosod; i > 0; i--) |
| 1237 | skip_bits(&s->gb, 8); | 1237 | skip_bits(&s->gb, 8); |
| 1238 | |||
| 1238 | next_field: | 1239 | next_field: |
| 1239 | for (i = 0; i < nb_components; i++) | 1240 | for (i = 0; i < nb_components; i++) |
| 1240 | s->last_dc[i] = 1024; | 1241 | s->last_dc[i] = 1024; |
| @@ -1271,11 +1272,14 @@ next_field: · 30 unmodified lines | |||
| 1271 | return ret; | 1272 | return ret; |
| 1272 | } | 1273 | } |
| 1273 | } | 1274 | } |
| 1274 | if(s->interlaced && get_bits_left(&s->gb) > 32 && show_bits(&s->gb, 8) == 0xFF) { | 1275 | |
| 1275 | GetBitContext bak= s->gb; | 1276 | if (s->interlaced && |
| 1277 | get_bits_left(&s->gb) > 32 && | ||
| 1278 | show_bits(&s->gb, 8) == 0xFF) { | ||
| 1279 | GetBitContext bak = s->gb; | ||
| 1276 | align_get_bits(&bak); | 1280 | align_get_bits(&bak); |
| 1277 | if(show_bits(&bak, 16) == 0xFFD1) { | 1281 | if (show_bits(&bak, 16) == 0xFFD1) { |
| 1278 | av_log(s->avctx, AV_LOG_DEBUG, "AVRn ingterlaced picture\n"); | 1282 | av_log(s->avctx, AV_LOG_DEBUG, "AVRn interlaced picture marker found\n"); |
| 1279 | s->gb = bak; | 1283 | s->gb = bak; |
| 1280 | skip_bits(&s->gb, 16); | 1284 | skip_bits(&s->gb, 16); |
| 1281 | s->bottom_field ^= 1; | 1285 | s->bottom_field ^= 1; |
| @@ -1177,8 +1177,9 @@ static av_cold int vorbis_encode_init(AVCodecContext *avccontext) · 1176 unmodified lines | |||
| 1177 | if ((ret = create_vorbis_context(venc, avccontext)) < 0) | 1177 | if ((ret = create_vorbis_context(venc, avccontext)) < 0) |
| 1178 | goto error; | 1178 | goto error; |
| 1179 | 1179 | ||
| 1180 | avccontext->bit_rate = 0; | ||
| 1180 | if (avccontext->flags & CODEC_FLAG_QSCALE) | 1181 | if (avccontext->flags & CODEC_FLAG_QSCALE) |
| 1181 | venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.; | 1182 | venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA; |
| 1182 | else | 1183 | else |
| 1183 | venc->quality = 8; | 1184 | venc->quality = 8; |
| 1184 | venc->quality *= venc->quality; | 1185 | venc->quality *= venc->quality; |