Allocating edges will be removed from generic code, so the encoder must handle this explicitly.
Unified · Split
| @@ -422,15 +422,21 @@ fail: · 421 unmodified lines | ||
| 422 | 422 | */ |
| 423 | 423 | static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) |
| 424 | 424 | { |
| 425 | + int edges_needed = av_codec_is_encoder(s->avctx->codec); | |
| 425 | 426 | int r, ret; |
| 426 | 427 | |
| 427 | 428 | pic->tf.f = &pic->f; |
| 428 | 429 | if (s->codec_id != AV_CODEC_ID_WMV3IMAGE && |
| 429 | 430 | s->codec_id != AV_CODEC_ID_VC1IMAGE && |
| 430 | − s->codec_id != AV_CODEC_ID_MSS2) | |
| 431 | + s->codec_id != AV_CODEC_ID_MSS2) { | |
| 432 | + if (edges_needed) { | |
| 433 | + pic->f.width = s->avctx->width + 2 * EDGE_WIDTH; | |
| 434 | + pic->f.height = s->avctx->height + 2 * EDGE_WIDTH; | |
| 435 | + } | |
| 436 | + | |
| 431 | 437 | r = ff_thread_get_buffer(s->avctx, &pic->tf, |
| 432 | 438 | pic->reference ? AV_GET_BUFFER_FLAG_REF : 0); |
| 433 | − else { | |
| 439 | + } else { | |
| 434 | 440 | pic->f.width = s->avctx->width; |
| 435 | 441 | pic->f.height = s->avctx->height; |
| 436 | 442 | pic->f.format = s->avctx->pix_fmt; |
| @@ -443,6 +449,18 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) · 6 unmodified lines | ||
| 443 | 449 | return -1; |
| 444 | 450 | } |
| 445 | 451 | |
| 452 | + if (edges_needed) { | |
| 453 | + int i; | |
| 454 | + for (i = 0; pic->f.data[i]; i++) { | |
| 455 | + int offset = (EDGE_WIDTH >> (i ? s->chroma_y_shift : 0)) * | |
| 456 | + pic->f.linesize[i] + | |
| 457 | + (EDGE_WIDTH >> (i ? s->chroma_x_shift : 0)); | |
| 458 | + pic->f.data[i] += offset; | |
| 459 | + } | |
| 460 | + pic->f.width = s->avctx->width; | |
| 461 | + pic->f.height = s->avctx->height; | |
| 462 | + } | |
| 463 | + | |
| 446 | 464 | if (s->avctx->hwaccel) { |
| 447 | 465 | assert(!pic->hwaccel_picture_private); |
| 448 | 466 | if (s->avctx->hwaccel->priv_data_size) { |