30 #include <schroedinger/schro.h>
31 #include <schroedinger/schrodebug.h>
32 #include <schroedinger/schrovideoformat.h>
88 for (idx = 0; idx < num_formats; ++idx) {
91 p_schro_params->
format->chroma_format =
98 "This codec currently only supports planar YUV 4:2:0, 4:2:2"
99 " and 4:4:4 formats.\n");
107 SchroVideoFormatEnum preset;
113 p_schro_params->
encoder = schro_encoder_new();
115 if (!p_schro_params->
encoder) {
117 "Unrecoverable Error: schro_encoder_new failed. ");
124 schro_encoder_get_video_format(p_schro_params->
encoder);
125 schro_video_format_set_std_video_format(p_schro_params->
format, preset);
133 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_HDTV;
135 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_625;
137 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_525;
141 p_schro_params->
format->colour_matrix = SCHRO_COLOUR_MATRIX_HDTV;
143 p_schro_params->
format->colour_matrix = SCHRO_COLOUR_MATRIX_SDTV;
147 p_schro_params->
format->transfer_function = SCHRO_TRANSFER_CHAR_TV_GAMMA;
153 "This codec currently supports only planar YUV 4:2:0, 4:2:2"
154 " and 4:4:4 formats.\n");
168 schro_encoder_setting_set_double(p_schro_params->
encoder,
170 SCHRO_ENCODER_GOP_INTRA_ONLY);
173 schro_encoder_setting_set_double(p_schro_params->
encoder,
174 "enable_noarith", 1);
176 schro_encoder_setting_set_double(p_schro_params->
encoder,
177 "au_distance", avccontext->
gop_size);
179 p_schro_params->
dts = -1;
186 schro_encoder_setting_set_double(p_schro_params->
encoder,
188 SCHRO_ENCODER_RATE_CONTROL_LOSSLESS);
191 schro_encoder_setting_set_double(p_schro_params->
encoder,
193 SCHRO_ENCODER_RATE_CONTROL_CONSTANT_QUALITY);
198 schro_encoder_setting_set_double(p_schro_params->
encoder,
202 schro_encoder_setting_set_double(p_schro_params->
encoder,
204 SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE);
206 schro_encoder_setting_set_double(p_schro_params->
encoder,
215 schro_encoder_setting_set_double(p_schro_params->
encoder,
216 "interlaced_coding", 1);
218 schro_encoder_setting_set_double(p_schro_params->
encoder,
"open_gop",
223 schro_video_format_set_std_signal_range(p_schro_params->
format,
224 SCHRO_SIGNAL_RANGE_8BIT_VIDEO);
227 schro_encoder_set_video_format(p_schro_params->
encoder,
231 schro_debug_set_level(avccontext->
debug);
233 schro_encoder_start(p_schro_params->
encoder);
244 SchroFrame *in_frame;
253 in_frame->components[0].data,
272 SchroEncoder *encoder = p_schro_params->
encoder;
275 SchroBuffer *enc_buf;
276 int presentation_frame;
278 int last_frame_in_sequence = 0;
284 schro_encoder_end_of_stream(encoder);
292 schro_encoder_push_frame(encoder, in_frame);
300 SchroStateEnum
state;
301 state = schro_encoder_wait(encoder);
303 case SCHRO_STATE_HAVE_BUFFER:
304 case SCHRO_STATE_END_OF_STREAM:
305 enc_buf = schro_encoder_pull(encoder, &presentation_frame);
307 parse_code = enc_buf->data[4];
317 enc_buf->data, enc_buf->length);
321 if (state == SCHRO_STATE_END_OF_STREAM) {
326 if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {
327 schro_buffer_unref(enc_buf);
336 if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) &&
337 SCHRO_PARSE_CODE_IS_REFERENCE(parse_code))
349 schro_buffer_unref(enc_buf);
353 case SCHRO_STATE_NEED_FRAME:
357 case SCHRO_STATE_AGAIN:
370 last_frame_in_sequence = 1;
377 pkt_size = p_frame_output->
size;
378 if (last_frame_in_sequence && p_schro_params->
enc_buf_size > 0)
390 pkt->
dts = p_schro_params->
dts++;
391 enc_size = p_frame_output->
size;
395 if (last_frame_in_sequence && p_schro_params->
enc_buf_size > 0) {
396 memcpy(pkt->
data + enc_size, p_schro_params->
enc_buf,
419 schro_encoder_free(p_schro_params->
encoder);
438 .
name =
"libschroedinger",