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);
290 schro_encoder_push_frame(encoder, in_frame);
299 SchroStateEnum
state;
300 state = schro_encoder_wait(encoder);
302 case SCHRO_STATE_HAVE_BUFFER:
303 case SCHRO_STATE_END_OF_STREAM:
304 enc_buf = schro_encoder_pull(encoder, &presentation_frame);
305 if (enc_buf->length <= 0)
307 parse_code = enc_buf->data[4];
315 enc_buf->length)) < 0) {
321 enc_buf->data, enc_buf->length);
325 if (state == SCHRO_STATE_END_OF_STREAM) {
330 if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {
331 schro_buffer_unref(enc_buf);
342 if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) &&
343 SCHRO_PARSE_CODE_IS_REFERENCE(parse_code))
355 schro_buffer_unref(enc_buf);
359 case SCHRO_STATE_NEED_FRAME:
363 case SCHRO_STATE_AGAIN:
376 last_frame_in_sequence = 1;
383 pkt_size = p_frame_output->
size;
384 if (last_frame_in_sequence && p_schro_params->
enc_buf_size > 0)
396 pkt->
dts = p_schro_params->
dts++;
397 enc_size = p_frame_output->
size;
401 if (last_frame_in_sequence && p_schro_params->
enc_buf_size > 0) {
402 memcpy(pkt->
data + enc_size, p_schro_params->
enc_buf,
425 schro_encoder_free(p_schro_params->
encoder);
446 .
name =
"libschroedinger",