And not just those with the old decode() API.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -292,7 +292,6 @@ static int64_t guess_correct_pts(AVCodecContext *ctx, · 291 unmodified lines | ||
| 292 | 292 | static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples) |
| 293 | 293 | { |
| 294 | 294 | AVCodecInternal *avci = avctx->internal; |
| 295 | − int ret = 0; | |
| 296 | 295 | AVFrameSideData *side; |
| 297 | 296 | uint32_t discard_padding = 0; |
| 298 | 297 | uint8_t skip_reason = 0; |
| @@ -309,26 +308,6 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca · 10 unmodified lines | ||
| 309 | 308 | discard_reason = AV_RL8(side->data + 9); |
| 310 | 309 | } |
| 311 | 310 | |
| 312 | − if (frame->format == AV_SAMPLE_FMT_NONE) | |
| 313 | − frame->format = avctx->sample_fmt; | |
| 314 | − if (!frame->ch_layout.nb_channels) { | |
| 315 | − int ret2 = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); | |
| 316 | − if (ret2 < 0) { | |
| 317 | − ret = ret2; | |
| 318 | − } | |
| 319 | − } | |
| 320 | −#if FF_API_OLD_CHANNEL_LAYOUT | |
| 321 | −FF_DISABLE_DEPRECATION_WARNINGS | |
| 322 | − if (!frame->channel_layout) | |
| 323 | − frame->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? | |
| 324 | − avctx->ch_layout.u.mask : 0; | |
| 325 | − if (!frame->channels) | |
| 326 | − frame->channels = avctx->ch_layout.nb_channels; | |
| 327 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 328 | −#endif | |
| 329 | − if (!frame->sample_rate) | |
| 330 | − frame->sample_rate = avctx->sample_rate; | |
| 331 | − | |
| 332 | 311 | if ((avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { |
| 333 | 312 | if (!side && (avci->skip_samples || discard_padding)) |
| 334 | 313 | side = av_frame_new_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES, 10); |
| @@ -339,7 +318,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 4 unmodified lines | ||
| 339 | 318 | AV_WL8(side->data + 9, discard_reason); |
| 340 | 319 | avci->skip_samples = 0; |
| 341 | 320 | } |
| 342 | − return ret; | |
| 321 | + return 0; | |
| 343 | 322 | } |
| 344 | 323 | av_frame_remove_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES); |
| 345 | 324 | |
| @@ -399,7 +378,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 53 unmodified lines | ||
| 399 | 378 | } |
| 400 | 379 | } |
| 401 | 380 | |
| 402 | − return ret; | |
| 381 | + return 0; | |
| 403 | 382 | } |
| 404 | 383 | |
| 405 | 384 | /* |
| @@ -449,14 +428,6 @@ FF_DISABLE_DEPRECATION_WARNINGS · 43 unmodified lines | ||
| 449 | 428 | frame->pkt_pos = pkt->pos; |
| 450 | 429 | FF_ENABLE_DEPRECATION_WARNINGS |
| 451 | 430 | #endif |
| 452 | − //FIXME these should be under if(!avctx->has_b_frames) | |
| 453 | − /* get_buffer is supposed to set frame parameters */ | |
| 454 | − if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) { | |
| 455 | − if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio; | |
| 456 | − if (!frame->width) frame->width = avctx->width; | |
| 457 | − if (!frame->height) frame->height = avctx->height; | |
| 458 | − if (frame->format == AV_PIX_FMT_NONE) frame->format = avctx->pix_fmt; | |
| 459 | − } | |
| 460 | 431 | } |
| 461 | 432 | } |
| 462 | 433 | emms_c(); |
| @@ -570,6 +541,45 @@ static int detect_colorspace(av_unused AVCodecContext *c, av_unused AVFrame *f) · 107 unmodified lines | ||
| 570 | 541 | } |
| 571 | 542 | #endif |
| 572 | 543 | |
| 544 | +static int fill_frame_props(AVCodecContext *avctx, AVFrame *frame) | |
| 545 | +{ | |
| 546 | + int ret; | |
| 547 | + | |
| 548 | + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { | |
| 549 | + //FIXME these should be under if(!avctx->has_b_frames) | |
| 550 | + /* get_buffer is supposed to set frame parameters */ | |
| 551 | + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) { | |
| 552 | + if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio; | |
| 553 | + if (!frame->width) frame->width = avctx->width; | |
| 554 | + if (!frame->height) frame->height = avctx->height; | |
| 555 | + if (frame->format == AV_PIX_FMT_NONE) frame->format = avctx->pix_fmt; | |
| 556 | + } | |
| 557 | + } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { | |
| 558 | + if (frame->format == AV_SAMPLE_FMT_NONE) | |
| 559 | + frame->format = avctx->sample_fmt; | |
| 560 | + if (!frame->ch_layout.nb_channels) { | |
| 561 | + ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); | |
| 562 | + if (ret < 0) { | |
| 563 | + av_frame_unref(frame); | |
| 564 | + return ret; | |
| 565 | + } | |
| 566 | + } | |
| 567 | +#if FF_API_OLD_CHANNEL_LAYOUT | |
| 568 | +FF_DISABLE_DEPRECATION_WARNINGS | |
| 569 | + if (!frame->channel_layout) | |
| 570 | + frame->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? | |
| 571 | + avctx->ch_layout.u.mask : 0; | |
| 572 | + if (!frame->channels) | |
| 573 | + frame->channels = avctx->ch_layout.nb_channels; | |
| 574 | +FF_ENABLE_DEPRECATION_WARNINGS | |
| 575 | +#endif | |
| 576 | + if (!frame->sample_rate) | |
| 577 | + frame->sample_rate = avctx->sample_rate; | |
| 578 | + } | |
| 579 | + | |
| 580 | + return 0; | |
| 581 | +} | |
| 582 | + | |
| 573 | 583 | static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame) |
| 574 | 584 | { |
| 575 | 585 | int ret; |
| @@ -621,6 +631,13 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 45 unmodified lines | ||
| 621 | 631 | if (!ret) { |
| 622 | 632 | if (avctx->codec_type != AVMEDIA_TYPE_VIDEO) |
| 623 | 633 | frame->flags |= AV_FRAME_FLAG_KEY; |
| 634 | + | |
| 635 | + ret = fill_missing_fields(avctx, frame); | |
| 636 | + if (ret < 0) { | |
| 637 | + av_frame_unref(frame); | |
| 638 | + return ret; | |
| 639 | + } | |
| 640 | + | |
| 624 | 641 | #if FF_API_FRAME_KEY |
| 625 | 642 | FF_DISABLE_DEPRECATION_WARNINGS |
| 626 | 643 | frame->key_frame = !!(frame->flags & AV_FRAME_FLAG_KEY); |