From patchwork Sun Aug 7 23:15:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Reid X-Patchwork-Id: 117 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp2742677vsd; Sun, 7 Aug 2016 16:15:51 -0700 (PDT) X-Received: by 10.194.96.205 with SMTP id du13mr84952733wjb.89.1470611750984; Sun, 07 Aug 2016 16:15:50 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h130si17986777wme.36.2016.08.07.16.15.50; Sun, 07 Aug 2016 16:15:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EB40A68A10C; Mon, 8 Aug 2016 02:15:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B7C8368A0FE for ; Mon, 8 Aug 2016 02:15:26 +0300 (EEST) Received: by mail-pf0-f194.google.com with SMTP id y134so23840968pfg.3 for ; Sun, 07 Aug 2016 16:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ZhEM9r5yOJUpMKguVgRQm9zOJTaV8Wz9zWRhHX4RNUo=; b=YN2EQQg6l0ZeCWgVU0zaNBVZinNd348m4VLhJOVVkz9X6u/uds927TLl6OtG+xG7uM B1oj+bWsGqacLfkXizXE9POUiBiC0N4O3BjobwbOp65JM50ePKILAoVTHoRl47P1Uqr2 SiMHoP2QHACFOAz+F/X+k9ioVAxImb7KEiDV///7KrV9o75tsAhHs0T+8J2+/RHHMd91 +NYyMQ2lnNGcVh8zvLSIONDLhgAcRmGJotIkbUwiUaVgiRnpodU++XuaoFQKSIdIOKFt 5GT4uZ7Ry/zAcmv9554fmlfq2yNllDy3bvUtj78veUKk1sTyOZBhOGrG6NAbc3s96ouL o7og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZhEM9r5yOJUpMKguVgRQm9zOJTaV8Wz9zWRhHX4RNUo=; b=O7w2VEc6wfch2+5SNQ/L/+JVKAVBx5lEo6oiPkxsUOLz0ZqYqcSuIP2LM0xQEeDI+m 4T4BP+marFXGeSA74dnpQVOLWfi8a5lX4eZpI0M8zcRICYYVKfUmYRlr0WQ0hCev1eQv e07oJlW/5E8K6eKvtqfxZmzD/Y7qS44kIT3zaCHswjoNSRPXnwd7HvvDzAONmvJOsjBA zTdkymD87RI8EGiLQWCszBC1HTDfS7JBriCesocEwMmymLVpkYMqQViPvaLe4WjkX9Kb 6QAEo6EMcAGBey/ECQwxCEh4ncA6qHYzBETJfJuwo05uytfaYMqhjvnd1ZOn7sWXSnnY ft0A== X-Gm-Message-State: AEkoouuiMZ6nw8GweNwB770c8JPKFNQc21MqRG5d7hemRuyYni904OLov6f1lJJTdQ6xWg== X-Received: by 10.98.35.7 with SMTP id j7mr157444703pfj.39.1470611732783; Sun, 07 Aug 2016 16:15:32 -0700 (PDT) Received: from localhost.localdomain (S0106ac228b6e4f8e.vc.shawcable.net. [24.86.211.88]) by smtp.gmail.com with ESMTPSA id v124sm42785256pfb.14.2016.08.07.16.15.31 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 07 Aug 2016 16:15:32 -0700 (PDT) From: Mark Reid To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Aug 2016 16:15:27 -0700 Message-Id: <20160807231528.21386-1-mindmark@gmail.com> X-Mailer: git-send-email 2.9.2 Subject: [FFmpeg-devel] [PATCH 1/2] libavcodec/dnxhdenc: add edge emulate for dnxhr X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Mark Reid MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi This patch fixes dnxhr encoders handling for resolutions that are not multiples of 16. --- libavcodec/dnxhdenc.c | 71 +++++++++++++++++++++++++++++++++++++++------------ libavcodec/dnxhdenc.h | 2 ++ 2 files changed, 56 insertions(+), 17 deletions(-) -- 2.9.2 diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index b0ee8a2..d8289a4 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -368,6 +368,9 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) ff_pixblockdsp_init(&ctx->m.pdsp, avctx); ff_dct_encode_init(&ctx->m); + if (ctx->profile != FF_PROFILE_DNXHD) + ff_videodsp_init(&ctx->m.vdsp, bit_depth); + if (!ctx->m.dct_quantize) ctx->m.dct_quantize = ff_dct_quantize_c; @@ -617,6 +620,10 @@ void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) { const int bs = ctx->block_width_l2; const int bw = 1 << bs; + int dct_y_offset = ctx->dct_y_offset; + int dct_uv_offset = ctx->dct_uv_offset; + int linesize = ctx->m.linesize; + int uvlinesize = ctx->m.uvlinesize; const uint8_t *ptr_y = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize) + (mb_x << bs + 1); const uint8_t *ptr_u = ctx->thread[0]->src[1] + @@ -624,26 +631,56 @@ void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs); PixblockDSPContext *pdsp = &ctx->m.pdsp; + VideoDSPContext *vdsp = &ctx->m.vdsp; + + if (vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > ctx->m.avctx->width || + (mb_y << 4) + 16 > ctx->m.avctx->height)) { + int y_w = ctx->m.avctx->width - (mb_x << 4); + int y_h = ctx->m.avctx->height - (mb_y << 4); + int uv_w = (y_w + 1) / 2; + int uv_h = y_h; + linesize = 16; + uvlinesize = 8; + + vdsp->emulated_edge_mc(&ctx->edge_buf_y[0], ptr_y, + linesize, ctx->m.linesize, + linesize, 16, + 0, 0, y_w, y_h); + vdsp->emulated_edge_mc(&ctx->edge_buf_uv[0][0], ptr_u, + uvlinesize, ctx->m.uvlinesize, + uvlinesize, 16, + 0, 0, uv_w, uv_h); + vdsp->emulated_edge_mc(&ctx->edge_buf_uv[1][0], ptr_v, + uvlinesize, ctx->m.uvlinesize, + uvlinesize, 16, + 0, 0, uv_w, uv_h); + + dct_y_offset = bw * linesize; + dct_uv_offset = bw * uvlinesize; + ptr_y = &ctx->edge_buf_y[0]; + ptr_u = &ctx->edge_buf_uv[0][0]; + ptr_v = &ctx->edge_buf_uv[1][0]; + } - pdsp->get_pixels(ctx->blocks[0], ptr_y, ctx->m.linesize); - pdsp->get_pixels(ctx->blocks[1], ptr_y + bw, ctx->m.linesize); - pdsp->get_pixels(ctx->blocks[2], ptr_u, ctx->m.uvlinesize); - pdsp->get_pixels(ctx->blocks[3], ptr_v, ctx->m.uvlinesize); + pdsp->get_pixels(ctx->blocks[0], ptr_y, linesize); + pdsp->get_pixels(ctx->blocks[1], ptr_y + bw, linesize); + pdsp->get_pixels(ctx->blocks[2], ptr_u, uvlinesize); + pdsp->get_pixels(ctx->blocks[3], ptr_v, uvlinesize); - if (mb_y + 1 == ctx->m.mb_height && (ctx->m.avctx->height % 16) != 0) { + if (mb_y + 1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) { if (ctx->interlaced) { ctx->get_pixels_8x4_sym(ctx->blocks[4], - ptr_y + ctx->dct_y_offset, - ctx->m.linesize); + ptr_y + dct_y_offset, + linesize); ctx->get_pixels_8x4_sym(ctx->blocks[5], - ptr_y + ctx->dct_y_offset + bw, - ctx->m.linesize); + ptr_y + dct_y_offset + bw, + linesize); ctx->get_pixels_8x4_sym(ctx->blocks[6], - ptr_u + ctx->dct_uv_offset, - ctx->m.uvlinesize); + ptr_u + dct_uv_offset, + uvlinesize); ctx->get_pixels_8x4_sym(ctx->blocks[7], - ptr_v + ctx->dct_uv_offset, - ctx->m.uvlinesize); + ptr_v + dct_uv_offset, + uvlinesize); } else { ctx->bdsp.clear_block(ctx->blocks[4]); ctx->bdsp.clear_block(ctx->blocks[5]); @@ -652,13 +689,13 @@ void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) } } else { pdsp->get_pixels(ctx->blocks[4], - ptr_y + ctx->dct_y_offset, ctx->m.linesize); + ptr_y + dct_y_offset, linesize); pdsp->get_pixels(ctx->blocks[5], - ptr_y + ctx->dct_y_offset + bw, ctx->m.linesize); + ptr_y + dct_y_offset + bw, linesize); pdsp->get_pixels(ctx->blocks[6], - ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize); + ptr_u + dct_uv_offset, uvlinesize); pdsp->get_pixels(ctx->blocks[7], - ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize); + ptr_v + dct_uv_offset, uvlinesize); } } diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 7f8e7b3..96a79aa 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -71,6 +71,8 @@ typedef struct DNXHDEncContext { int intra_quant_bias; DECLARE_ALIGNED(16, int16_t, blocks)[8][64]; + uint8_t edge_buf_y[256]; + uint8_t edge_buf_uv[2][128]; int (*qmatrix_c) [64]; int (*qmatrix_l) [64];