FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
libschroedinger.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22 * @file
23 * data structures common to libschroedinger decoder and encoder
24 */
25 
26 #ifndef AVCODEC_LIBSCHROEDINGER_H
27 #define AVCODEC_LIBSCHROEDINGER_H
28 
29 #include <schroedinger/schrobitstream.h>
30 #include <schroedinger/schroframe.h>
31 
32 #include "avcodec.h"
33 
34 typedef struct SchroVideoFormatInfo {
35  uint16_t width;
36  uint16_t height;
37  uint16_t frame_rate_num;
38  uint16_t frame_rate_denom;
40 
41 /**
42 * contains a single encoded frame returned from Dirac or Schroedinger
43 */
44 typedef struct FFSchroEncodedFrame {
45  /** encoded frame data */
47 
48  /** encoded frame size */
49  uint32_t size;
50 
51  /** encoded frame number. Will be used as pts */
52  uint32_t frame_num;
53 
54  /** key frame flag. 1 : is key frame , 0 : in not key frame */
55  uint16_t key_frame;
57 
58 /**
59 * queue element
60 */
61 typedef struct FFSchroQueueElement {
62  /** Data to be stored in queue*/
63  void *data;
64  /** Pointer to next element queue */
67 
68 
69 /**
70 * A simple queue implementation used in libschroedinger
71 */
72 typedef struct FFSchroQueue {
73  /** Pointer to head of queue */
75  /** Pointer to tail of queue */
77  /** Queue size*/
78  int size;
79 } FFSchroQueue;
80 
81 /**
82 * Initialise the queue
83 */
85 
86 /**
87 * Add an element to the end of the queue
88 */
89 int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data);
90 
91 /**
92 * Return the first element in the queue
93 */
94 void *ff_schro_queue_pop(FFSchroQueue *queue);
95 
96 /**
97 * Free the queue resources. free_func is a function supplied by the caller to
98 * free any resources allocated by the caller. The data field of the queue
99 * element is passed to it.
100 */
101 void ff_schro_queue_free(FFSchroQueue *queue, void (*free_func)(void *));
102 
103 static const struct {
105  SchroChromaFormat schro_pix_fmt;
106  SchroFrameFormat schro_frame_fmt;
108  { AV_PIX_FMT_YUV420P, SCHRO_CHROMA_420, SCHRO_FRAME_FORMAT_U8_420 },
109  { AV_PIX_FMT_YUV422P, SCHRO_CHROMA_422, SCHRO_FRAME_FORMAT_U8_422 },
110  { AV_PIX_FMT_YUV444P, SCHRO_CHROMA_444, SCHRO_FRAME_FORMAT_U8_444 },
111 };
112 
113 /**
114 * Returns the video format preset matching the input video dimensions and
115 * time base.
116 */
117 SchroVideoFormatEnum ff_get_schro_video_format_preset (AVCodecContext *avctx);
118 
119 /**
120 * Sets the Schroedinger frame format corresponding to the Schro chroma format
121 * passed. Returns 0 on success, -1 on failure.
122 */
123 int ff_get_schro_frame_format(SchroChromaFormat schro_chroma_fmt,
124  SchroFrameFormat *schro_frame_fmt);
125 
126 /**
127 * Create a Schro frame based on the dimensions and frame format
128 * passed. Returns a pointer to a frame on success, NULL on failure.
129 */
130 SchroFrame *ff_create_schro_frame(AVCodecContext *avctx,
131  SchroFrameFormat schro_frame_fmt);
132 
133 #endif /* AVCODEC_LIBSCHROEDINGER_H */
FFSchroQueueElement * p_tail
Pointer to tail of queue.
void * data
Data to be stored in queue.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
SchroChromaFormat schro_pix_fmt
uint16_t key_frame
key frame flag.
enum AVPixelFormat ff_pix_fmt
uint8_t
uint32_t frame_num
encoded frame number.
void ff_schro_queue_free(FFSchroQueue *queue, void(*free_func)(void *))
Free the queue resources.
contains a single encoded frame returned from Dirac or Schroedinger
SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avctx)
Returns the video format preset matching the input video dimensions and time base.
int size
Queue size.
uint8_t * p_encbuf
encoded frame data
static const struct @86 schro_pixel_format_map[]
void * ff_schro_queue_pop(FFSchroQueue *queue)
Return the first element in the queue.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
A simple queue implementation used in libschroedinger.
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1743
SchroFrameFormat schro_frame_fmt
int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data)
Add an element to the end of the queue.
struct FFSchroQueueElement * next
Pointer to next element queue.
FFSchroQueueElement * p_head
Pointer to head of queue.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
void ff_schro_queue_init(FFSchroQueue *queue)
Initialise the queue.
queue element
SchroFrame * ff_create_schro_frame(AVCodecContext *avctx, SchroFrameFormat schro_frame_fmt)
Create a Schro frame based on the dimensions and frame format passed.
uint32_t size
encoded frame size
int ff_get_schro_frame_format(SchroChromaFormat schro_chroma_fmt, SchroFrameFormat *schro_frame_fmt)
Sets the Schroedinger frame format corresponding to the Schro chroma format passed.
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60