Unified · Split
| @@ -270,6 +270,32 @@ fail: · 269 unmodified lines | |||
| 270 | return ret; | 270 | return ret; |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | static int av_cold alloc_dummy_frame(MpegEncContext *s, Picture **picp) | ||
| 274 | { | ||
| 275 | int idx = ff_find_unused_picture(s->avctx, s->picture, 0); | ||
| 276 | Picture *pic; | ||
| 277 | int ret; | ||
| 278 | |||
| 279 | if (idx < 0) | ||
| 280 | return idx; | ||
| 281 | |||
| 282 | pic = &s->picture[idx]; | ||
| 283 | |||
| 284 | pic->reference = 3; | ||
| 285 | pic->f->pict_type = AV_PICTURE_TYPE_P; | ||
| 286 | |||
| 287 | ret = alloc_picture(s, pic); | ||
| 288 | if (ret < 0) | ||
| 289 | return ret; | ||
| 290 | |||
| 291 | ff_thread_report_progress(&pic->tf, INT_MAX, 0); | ||
| 292 | ff_thread_report_progress(&pic->tf, INT_MAX, 1); | ||
| 293 | |||
| 294 | *picp = pic; | ||
| 295 | |||
| 296 | return 0; | ||
| 297 | } | ||
| 298 | |||
| 273 | static void color_frame(AVFrame *frame, int luma) | 299 | static void color_frame(AVFrame *frame, int luma) |
| 274 | { | 300 | { |
| 275 | int h_chroma_shift, v_chroma_shift; | 301 | int h_chroma_shift, v_chroma_shift; |
| @@ -379,48 +405,22 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 103 unmodified lines | |||
| 379 | "warning: first frame is no keyframe\n"); | 405 | "warning: first frame is no keyframe\n"); |
| 380 | 406 | ||
| 381 | /* Allocate a dummy frame */ | 407 | /* Allocate a dummy frame */ |
| 382 | idx = ff_find_unused_picture(s->avctx, s->picture, 0); | 408 | ret = alloc_dummy_frame(s, &s->last_picture_ptr); |
| 383 | if (idx < 0) { | 409 | if (ret < 0) |
| 384 | av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); | 410 | return ret; |
| 385 | return idx; | ||
| 386 | } | ||
| 387 | s->last_picture_ptr = &s->picture[idx]; | ||
| 388 | |||
| 389 | s->last_picture_ptr->reference = 3; | ||
| 390 | s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P; | ||
| 391 | |||
| 392 | if (alloc_picture(s, s->last_picture_ptr) < 0) { | ||
| 393 | s->last_picture_ptr = NULL; | ||
| 394 | return -1; | ||
| 395 | } | ||
| 396 | 411 | ||
| 397 | if (!avctx->hwaccel) { | 412 | if (!avctx->hwaccel) { |
| 398 | int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80; | 413 | int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80; |
| 399 | color_frame(s->last_picture_ptr->f, luma_val); | 414 | color_frame(s->last_picture_ptr->f, luma_val); |
| 400 | } | 415 | } |
| 401 | 416 | ||
| 402 | ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0); | ||
| 403 | ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1); | ||
| 404 | } | 417 | } |
| 405 | if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) && | 418 | if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) && |
| 406 | s->pict_type == AV_PICTURE_TYPE_B) { | 419 | s->pict_type == AV_PICTURE_TYPE_B) { |
| 407 | /* Allocate a dummy frame */ | 420 | /* Allocate a dummy frame */ |
| 408 | idx = ff_find_unused_picture(s->avctx, s->picture, 0); | 421 | ret = alloc_dummy_frame(s, &s->next_picture_ptr); |
| 409 | if (idx < 0) { | 422 | if (ret < 0) |
| 410 | av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); | 423 | return ret; |
| 411 | return idx; | ||
| 412 | } | ||
| 413 | s->next_picture_ptr = &s->picture[idx]; | ||
| 414 | |||
| 415 | s->next_picture_ptr->reference = 3; | ||
| 416 | s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P; | ||
| 417 | |||
| 418 | if (alloc_picture(s, s->next_picture_ptr) < 0) { | ||
| 419 | s->next_picture_ptr = NULL; | ||
| 420 | return -1; | ||
| 421 | } | ||
| 422 | ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 0); | ||
| 423 | ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1); | ||
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | if (s->last_picture_ptr) { | 426 | if (s->last_picture_ptr) { |