This has been done for the luma plane of missing FLV1 and H263 references. Also remove code duplication by reusing gray_frame(), which has been renamed to color_frame() for this purpose.
Unified · Split
| @@ -245,12 +245,12 @@ static int alloc_picture(MpegEncContext *s, Picture *pic) · 244 unmodified lines | ||
| 245 | 245 | &s->linesize, &s->uvlinesize); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | −static void gray_frame(AVFrame *frame) | |
| 248 | +static void color_frame(AVFrame *frame, int luma) | |
| 249 | 249 | { |
| 250 | 250 | int h_chroma_shift, v_chroma_shift; |
| 251 | 251 | |
| 252 | 252 | for (int i = 0; i < frame->height; i++) |
| 253 | − memset(frame->data[0] + frame->linesize[0] * i, 0x80, frame->width); | |
| 253 | + memset(frame->data[0] + frame->linesize[0] * i, luma, frame->width); | |
| 254 | 254 | |
| 255 | 255 | if (!frame->data[1]) |
| 256 | 256 | return; |
| @@ -365,9 +365,6 @@ FF_ENABLE_DEPRECATION_WARNINGS · 108 unmodified lines | ||
| 365 | 365 | |
| 366 | 366 | if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) && |
| 367 | 367 | (s->pict_type != AV_PICTURE_TYPE_I)) { |
| 368 | − int h_chroma_shift, v_chroma_shift; | |
| 369 | − av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, | |
| 370 | − &h_chroma_shift, &v_chroma_shift); | |
| 371 | 368 | if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f->buf[0]) |
| 372 | 369 | av_log(avctx, AV_LOG_DEBUG, |
| 373 | 370 | "allocating dummy last picture for B frame\n"); |
| @@ -393,23 +390,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 19 unmodified lines | ||
| 393 | 390 | } |
| 394 | 391 | |
| 395 | 392 | if (!avctx->hwaccel) { |
| 396 | − for (int i = 0; i < avctx->height; i++) | |
| 397 | − memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i, | |
| 398 | − 0x80, avctx->width); | |
| 399 | − if (s->last_picture_ptr->f->data[2]) { | |
| 400 | − for (int i = 0; i < AV_CEIL_RSHIFT(avctx->height, v_chroma_shift); i++) { | |
| 401 | − memset(s->last_picture_ptr->f->data[1] + s->last_picture_ptr->f->linesize[1]*i, | |
| 402 | − 0x80, AV_CEIL_RSHIFT(avctx->width, h_chroma_shift)); | |
| 403 | − memset(s->last_picture_ptr->f->data[2] + s->last_picture_ptr->f->linesize[2]*i, | |
| 404 | − 0x80, AV_CEIL_RSHIFT(avctx->width, h_chroma_shift)); | |
| 405 | − } | |
| 406 | − } | |
| 407 | − | |
| 408 | − if (s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263) { | |
| 409 | − for (int i = 0; i < avctx->height; i++) | |
| 410 | − memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0] * i, | |
| 411 | − 16, avctx->width); | |
| 412 | − } | |
| 393 | + int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80; | |
| 394 | + color_frame(s->last_picture_ptr->f, luma_val); | |
| 413 | 395 | } |
| 414 | 396 | |
| 415 | 397 | ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0); |
| @@ -480,7 +462,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 64 unmodified lines | ||
| 480 | 462 | } |
| 481 | 463 | |
| 482 | 464 | if (s->avctx->debug & FF_DEBUG_NOMC) |
| 483 | − gray_frame(s->current_picture_ptr->f); | |
| 465 | + color_frame(s->current_picture_ptr->f, 0x80); | |
| 484 | 466 | |
| 485 | 467 | return 0; |
| 486 | 468 | } |