30 #include <schroedinger/schro.h>
31 #include <schroedinger/schrodebug.h>
32 #include <schroedinger/schrovideoformat.h>
86 for (idx = 0; idx < num_formats; ++idx) {
88 p_schro_params->
format->chroma_format =
95 "This codec currently only supports planar YUV 4:2:0, 4:2:2"
96 " and 4:4:4 formats.\n");
104 SchroVideoFormatEnum
preset;
110 p_schro_params->
encoder = schro_encoder_new();
112 if (!p_schro_params->
encoder) {
114 "Unrecoverable Error: schro_encoder_new failed. ");
121 schro_encoder_get_video_format(p_schro_params->
encoder);
122 schro_video_format_set_std_video_format(p_schro_params->
format, preset);
130 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_HDTV;
132 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_625;
134 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_525;
138 p_schro_params->
format->colour_matrix = SCHRO_COLOUR_MATRIX_HDTV;
140 p_schro_params->
format->colour_matrix = SCHRO_COLOUR_MATRIX_SDTV;
144 p_schro_params->
format->transfer_function = SCHRO_TRANSFER_CHAR_TV_GAMMA;
150 "This codec currently supports only planar YUV 4:2:0, 4:2:2"
151 " and 4:4:4 formats.\n");
167 schro_encoder_setting_set_double(p_schro_params->
encoder,
169 SCHRO_ENCODER_GOP_INTRA_ONLY);
172 schro_encoder_setting_set_double(p_schro_params->
encoder,
173 "enable_noarith", 1);
175 schro_encoder_setting_set_double(p_schro_params->
encoder,
178 p_schro_params->
dts = -1;
185 schro_encoder_setting_set_double(p_schro_params->
encoder,
187 SCHRO_ENCODER_RATE_CONTROL_LOSSLESS);
190 schro_encoder_setting_set_double(p_schro_params->
encoder,
192 SCHRO_ENCODER_RATE_CONTROL_CONSTANT_QUALITY);
197 schro_encoder_setting_set_double(p_schro_params->
encoder,
201 schro_encoder_setting_set_double(p_schro_params->
encoder,
203 SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE);
205 schro_encoder_setting_set_double(p_schro_params->
encoder,
212 schro_encoder_setting_set_double(p_schro_params->
encoder,
213 "interlaced_coding", 1);
215 schro_encoder_setting_set_double(p_schro_params->
encoder,
"open_gop",
220 schro_video_format_set_std_signal_range(p_schro_params->
format,
221 SCHRO_SIGNAL_RANGE_8BIT_VIDEO);
224 schro_encoder_set_video_format(p_schro_params->
encoder,
228 schro_debug_set_level(avctx->
debug);
230 schro_encoder_start(p_schro_params->
encoder);
241 SchroFrame *in_frame;
250 in_frame->components[0].data,
269 SchroEncoder *encoder = p_schro_params->
encoder;
272 SchroBuffer *enc_buf;
273 int presentation_frame;
275 int last_frame_in_sequence = 0;
281 schro_encoder_end_of_stream(encoder);
288 schro_encoder_push_frame(encoder, in_frame);
296 SchroStateEnum
state;
297 state = schro_encoder_wait(encoder);
299 case SCHRO_STATE_HAVE_BUFFER:
300 case SCHRO_STATE_END_OF_STREAM:
301 enc_buf = schro_encoder_pull(encoder, &presentation_frame);
303 parse_code = enc_buf->data[4];
313 enc_buf->data, enc_buf->length);
317 if (state == SCHRO_STATE_END_OF_STREAM) {
322 if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {
323 schro_buffer_unref(enc_buf);
332 if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) &&
333 SCHRO_PARSE_CODE_IS_REFERENCE(parse_code))
343 p_schro_params->
enc_buf = NULL;
345 schro_buffer_unref(enc_buf);
349 case SCHRO_STATE_NEED_FRAME:
353 case SCHRO_STATE_AGAIN:
366 last_frame_in_sequence = 1;
373 pkt_size = p_frame_output->
size;
374 if (last_frame_in_sequence && p_schro_params->
enc_buf_size > 0)
386 pkt->
dts = p_schro_params->
dts++;
387 enc_size = p_frame_output->
size;
391 if (last_frame_in_sequence && p_schro_params->
enc_buf_size > 0) {
392 memcpy(pkt->
data + enc_size, p_schro_params->
enc_buf,
415 schro_encoder_free(p_schro_params->
encoder);
436 .
name =
"libschroedinger",