History

mpegvideo: allocate edges when encoding.

Allocating edges will be removed from generic code, so the encoder must handle this explicitly.

Anton Khirnov committed 12 years ago

Commit 024db241 parent f7e85ee1 file · +20 −2Browse files

Unified · Split

libavcodec/mpegvideo.c+20−2
@@ -422,15 +422,21 @@ fail: · 421 unmodified lines
422422 */
423423 static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
424424 {
425+ int edges_needed = av_codec_is_encoder(s->avctx->codec);
425426 int r, ret;
426427
427428 pic->tf.f = &pic->f;
428429 if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
429430 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+
431437 r = ff_thread_get_buffer(s->avctx, &pic->tf,
432438 pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
433− else {
439+ } else {
434440 pic->f.width = s->avctx->width;
435441 pic->f.height = s->avctx->height;
436442 pic->f.format = s->avctx->pix_fmt;
@@ -443,6 +449,18 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) · 6 unmodified lines
443449 return -1;
444450 }
445451
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+
446464 if (s->avctx->hwaccel) {
447465 assert(!pic->hwaccel_picture_private);
448466 if (s->avctx->hwaccel->priv_data_size) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t