1 /*****************************************************************************
2 * internal.c: video filter utilities
3 *****************************************************************************
4 * Copyright (C) 2010-2015 x264 project
6 * Authors: Steven Walters <kemuri9@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
22 * This program is also available under a commercial proprietary license.
23 * For more information, contact us at licensing@x264.com.
24 *****************************************************************************/
27 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "x264", __VA_ARGS__ )
29 void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int w, int h )
33 memcpy( dst, src, w );
39 int x264_cli_pic_copy( cli_pic_t *out, cli_pic_t *in )
41 int csp = in->img.csp & X264_CSP_MASK;
42 FAIL_IF_ERROR( x264_cli_csp_is_invalid( in->img.csp ), "invalid colorspace arg %d\n", in->img.csp )
43 FAIL_IF_ERROR( in->img.csp != out->img.csp || in->img.height != out->img.height
44 || in->img.width != out->img.width, "incompatible frame properties\n" );
46 out->duration = in->duration;
48 out->opaque = in->opaque;
50 for( int i = 0; i < out->img.planes; i++ )
52 int height = in->img.height * x264_cli_csps[csp].height[i];
53 int width = in->img.width * x264_cli_csps[csp].width[i];
54 width *= x264_cli_csp_depth_factor( in->img.csp );
55 x264_cli_plane_copy( out->img.plane[i], out->img.stride[i], in->img.plane[i],
56 in->img.stride[i], width, height );