33 #include <schroedinger/schro.h>
34 #include <schroedinger/schrodebug.h>
35 #include <schroedinger/schrovideoformat.h>
87 for (idx = 0; idx < num_formats; ++idx) {
90 p_schro_params->
format->chroma_format =
97 "This codec currently only supports planar YUV 4:2:0, 4:2:2"
98 " and 4:4:4 formats.\n");
106 SchroVideoFormatEnum preset;
112 p_schro_params->
encoder = schro_encoder_new();
114 if (!p_schro_params->
encoder) {
116 "Unrecoverable Error: schro_encoder_new failed. ");
123 schro_encoder_get_video_format(p_schro_params->
encoder);
124 schro_video_format_set_std_video_format(p_schro_params->
format, preset);
132 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_HDTV;
134 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_625;
136 p_schro_params->
format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_525;
140 p_schro_params->
format->colour_matrix = SCHRO_COLOUR_MATRIX_HDTV;
142 p_schro_params->
format->colour_matrix = SCHRO_COLOUR_MATRIX_SDTV;
146 p_schro_params->
format->transfer_function = SCHRO_TRANSFER_CHAR_TV_GAMMA;
152 "This codec currently supports only planar YUV 4:2:0, 4:2:2"
153 " 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,
176 "au_distance", avccontext->
gop_size);
184 schro_encoder_setting_set_double(p_schro_params->
encoder,
186 SCHRO_ENCODER_RATE_CONTROL_LOSSLESS);
189 schro_encoder_setting_set_double(p_schro_params->
encoder,
191 SCHRO_ENCODER_RATE_CONTROL_CONSTANT_QUALITY);
196 schro_encoder_setting_set_double(p_schro_params->
encoder,
200 schro_encoder_setting_set_double(p_schro_params->
encoder,
202 SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE);
204 schro_encoder_setting_set_double(p_schro_params->
encoder,
213 schro_encoder_setting_set_double(p_schro_params->
encoder,
214 "interlaced_coding", 1);
216 schro_encoder_setting_set_double(p_schro_params->
encoder,
"open_gop",
221 schro_video_format_set_std_signal_range(p_schro_params->
format,
222 SCHRO_SIGNAL_RANGE_8BIT_VIDEO);
225 schro_encoder_set_video_format(p_schro_params->
encoder,
229 schro_debug_set_level(avccontext->
debug);
231 schro_encoder_start(p_schro_params->
encoder);
242 SchroFrame *in_frame;
251 in_frame->components[0].data,
266 unsigned char *frame,
267 int buf_size,
void *
data)
271 SchroEncoder *encoder = p_schro_params->
encoder;
274 SchroBuffer *enc_buf;
275 int presentation_frame;
277 int last_frame_in_sequence = 0;
282 schro_encoder_end_of_stream(encoder);
290 schro_encoder_push_frame(encoder, in_frame);
298 SchroStateEnum
state;
299 state = schro_encoder_wait(encoder);
301 case SCHRO_STATE_HAVE_BUFFER:
302 case SCHRO_STATE_END_OF_STREAM:
303 enc_buf = schro_encoder_pull(encoder, &presentation_frame);
304 assert(enc_buf->length > 0);
305 assert(enc_buf->length <= buf_size);
306 parse_code = enc_buf->data[4];
316 enc_buf->data, enc_buf->length);
320 if (state == SCHRO_STATE_END_OF_STREAM) {
325 if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {
326 schro_buffer_unref(enc_buf);
335 if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) &&
336 SCHRO_PARSE_CODE_IS_REFERENCE(parse_code))
348 schro_buffer_unref(enc_buf);
352 case SCHRO_STATE_NEED_FRAME:
356 case SCHRO_STATE_AGAIN:
369 last_frame_in_sequence = 1;
376 memcpy(frame, p_frame_output->
p_encbuf, p_frame_output->
size);
382 enc_size = p_frame_output->
size;
386 if (last_frame_in_sequence && p_schro_params->
enc_buf_size > 0) {
387 memcpy(frame + enc_size, p_schro_params->
enc_buf,
406 schro_encoder_free(p_schro_params->
encoder);
425 .
name =
"libschroedinger",
uint32_t size
encoded frame size
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
AVFrame picture
frame being encoded
static int libschroedinger_encode_init(AVCodecContext *avccontext)
AV_WL32 AV_WL24 AV_WL16 AV_RB32
AVFrame * coded_frame
the picture in the bitstream
static int SetSchroChromaFormat(AVCodecContext *avccontext)
Works out Schro-compatible chroma format.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
uint8_t * p_encbuf
encoded frame data
libschroedinger encoder private data
four components are given, that's all.
data structures common to libschroedinger decoder and encoder
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
uint32_t frame_num
encoded frame number.
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
uint16_t key_frame
key frame flag.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
SchroFrame * ff_create_schro_frame(AVCodecContext *avccontext, SchroFrameFormat schro_frame_fmt)
Create a Schro frame based on the dimensions and frame format passed.
int64_t pts
presentation timestamp in time_base units (time when frame should be shown to user) If AV_NOPTS_VALUE...
contains a single encoded frame returned from Dirac or Schroedinger
int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)
Calculate the size in bytes that a picture of the given width and height would occupy if stored in th...
static SchroFrame * libschroedinger_frame_from_data(AVCodecContext *avccontext, void *in_data)
static int init(AVCodecParserContext *s)
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
SchroEncoder * encoder
Schroedinger encoder handle.
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
SchroFrameFormat frame_format
Schroedinger frame format.
void * ff_dirac_schro_queue_pop(DiracSchroQueue *queue)
Return the first element in the queue.
A simple queue implementation used in libdirac and libschroedinger.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
DiracSchroQueue enc_frame_queue
queue storing encoded frames
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
SchroVideoFormat * format
Schroedinger video format.
static int libschroedinger_encode_close(AVCodecContext *avccontext)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int ff_get_schro_frame_format(SchroChromaFormat schro_pix_fmt, SchroFrameFormat *schro_frame_fmt)
Sets the Schroedinger frame format corresponding to the Schro chroma format passed.
int enc_buf_size
Size of encoder buffer.
static int libschroedinger_encode_frame(AVCodecContext *avccontext, unsigned char *frame, int buf_size, void *data)
int bit_rate
the average bitrate
enum PixelFormat ff_pix_fmt
int width
picture width / height.
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avccontext)
Returns the video format preset matching the input video dimensions and time base.
int eos_signalled
end of sequence signalled
int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data)
Add an element to the end of the queue.
main external API structure.
static void close(AVCodecParserContext *s)
#define CODEC_FLAG_QSCALE
Use fixed qscale.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned char * enc_buf
buffer to store encoder output before writing it to the frame queue
#define FF_CODER_TYPE_VLC
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static void SchroedingerFreeFrame(void *data)
int eos_pulled
end of sequence pulled
int global_quality
Global quality for codecs which cannot change it per frame.
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
#define CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
#define CODEC_FLAG_CLOSED_GOP
AVCodec ff_libschroedinger_encoder
data structures common to libdirac and libschroedinger
int key_frame
1 -> keyframe, 0-> not
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
struct SchroEncoderParams SchroEncoderParams
libschroedinger encoder private data
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
void ff_dirac_schro_queue_init(DiracSchroQueue *queue)
Initialise the queue.
int avpicture_layout(const AVPicture *src, enum PixelFormat pix_fmt, int width, int height, unsigned char *dest, int dest_size)
Copy pixel data from an AVPicture into a buffer.
static const struct @28 schro_pixel_format_map[]
void ff_dirac_schro_queue_free(DiracSchroQueue *queue, void(*free_func)(void *))
Free the queue resources.