/*****************************************************************************1* internal.c: video filter utilities2*****************************************************************************3* Copyright (C) 2010-2016 x264 project4*5* Authors: Steven Walters <[email protected]>6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.20*21* This program is also available under a commercial proprietary license.22* For more information, contact us at [email protected].23*****************************************************************************/2425#include "internal.h"26#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "x264", __VA_ARGS__ )2728void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int w, int h )29{30while( h-- )31{32memcpy( dst, src, w );33dst += i_dst;34src += i_src;35}36}3738int x264_cli_pic_copy( cli_pic_t *out, cli_pic_t *in )39{40int csp = in->img.csp & X264_CSP_MASK;41FAIL_IF_ERROR( x264_cli_csp_is_invalid( in->img.csp ), "invalid colorspace arg %d\n", in->img.csp )42FAIL_IF_ERROR( in->img.csp != out->img.csp || in->img.height != out->img.height43|| in->img.width != out->img.width, "incompatible frame properties\n" );44/* copy data */45out->duration = in->duration;46out->pts = in->pts;47out->opaque = in->opaque;4849for( int i = 0; i < out->img.planes; i++ )50{51int height = in->img.height * x264_cli_csps[csp].height[i];52int width = in->img.width * x264_cli_csps[csp].width[i];53width *= x264_cli_csp_depth_factor( in->img.csp );54x264_cli_plane_copy( out->img.plane[i], out->img.stride[i], in->img.plane[i],55in->img.stride[i], width, height );56}57return 0;58}596061