/*****************************************************************************1* raw.c: raw muxer2*****************************************************************************3* Copyright (C) 2003-2016 x264 project4*5* Authors: Laurent Aimar <[email protected]>6* Loren Merritt <[email protected]>7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2 of the License, or11* (at your option) any later version.12*13* This program is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with this program; if not, write to the Free Software20* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.21*22* This program is also available under a commercial proprietary license.23* For more information, contact us at [email protected].24*****************************************************************************/2526#include "output.h"2728static int open_file( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt )29{30if( !strcmp( psz_filename, "-" ) )31*p_handle = stdout;32else if( !(*p_handle = x264_fopen( psz_filename, "w+b" )) )33return -1;3435return 0;36}3738static int set_param( hnd_t handle, x264_param_t *p_param )39{40return 0;41}4243static int write_headers( hnd_t handle, x264_nal_t *p_nal )44{45int size = p_nal[0].i_payload + p_nal[1].i_payload + p_nal[2].i_payload;4647if( fwrite( p_nal[0].p_payload, size, 1, (FILE*)handle ) )48return size;49return -1;50}5152static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_t *p_picture )53{54if( fwrite( p_nalu, i_size, 1, (FILE*)handle ) )55return i_size;56return -1;57}5859static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest_pts )60{61if( !handle || handle == stdout )62return 0;6364return fclose( (FILE*)handle );65}6667const cli_output_t raw_output = { open_file, set_param, write_headers, write_frame, close_file };68697071