Originally committed as revision 19652 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -45,18 +45,17 @@ static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] |
| 45 | 45 |
{ 4096, 2160, 24, 1 },
|
| 46 | 46 |
}; |
| 47 | 47 |
|
| 48 |
-unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext) |
|
| 48 |
+unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext) |
|
| 49 | 49 |
{
|
| 50 | 50 |
unsigned int ret_idx = 0; |
| 51 | 51 |
unsigned int idx; |
| 52 | 52 |
unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) / |
| 53 | 53 |
sizeof(ff_dirac_schro_video_format_info[0]); |
| 54 | 54 |
|
| 55 |
- for (idx = 1 ; idx < num_formats; ++idx ) {
|
|
| 56 |
- const FfmpegDiracSchroVideoFormatInfo *vf = |
|
| 57 |
- &ff_dirac_schro_video_format_info[idx]; |
|
| 55 |
+ for (idx = 1; idx < num_formats; ++idx) {
|
|
| 56 |
+ const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx]; |
|
| 58 | 57 |
if (avccontext->width == vf->width && |
| 59 |
- avccontext->height == vf->height){
|
|
| 58 |
+ avccontext->height == vf->height) {
|
|
| 60 | 59 |
ret_idx = idx; |
| 61 | 60 |
if (avccontext->time_base.den == vf->frame_rate_num && |
| 62 | 61 |
avccontext->time_base.num == vf->frame_rate_denom) |
| ... | ... |
@@ -66,23 +65,22 @@ unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext) |
| 66 | 66 |
return ret_idx; |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
-void ff_dirac_schro_queue_init (FfmpegDiracSchroQueue *queue) |
|
| 69 |
+void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue) |
|
| 70 | 70 |
{
|
| 71 | 71 |
queue->p_head = queue->p_tail = NULL; |
| 72 | 72 |
queue->size = 0; |
| 73 | 73 |
} |
| 74 | 74 |
|
| 75 |
-void ff_dirac_schro_queue_free (FfmpegDiracSchroQueue *queue, |
|
| 76 |
- void (*free_func)(void *)) |
|
| 75 |
+void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue, |
|
| 76 |
+ void (*free_func)(void *)) |
|
| 77 | 77 |
{
|
| 78 | 78 |
while (queue->p_head) |
| 79 |
- free_func( ff_dirac_schro_queue_pop(queue) ); |
|
| 79 |
+ free_func(ff_dirac_schro_queue_pop(queue)); |
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 |
-int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data) |
|
| 82 |
+int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data) |
|
| 83 | 83 |
{
|
| 84 |
- FfmpegDiracSchroQueueElement *p_new = |
|
| 85 |
- av_mallocz(sizeof(FfmpegDiracSchroQueueElement)); |
|
| 84 |
+ FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement)); |
|
| 86 | 85 |
|
| 87 | 86 |
if (!p_new) |
| 88 | 87 |
return -1; |
| ... | ... |
@@ -99,7 +97,7 @@ int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data) |
| 99 | 99 |
return 0; |
| 100 | 100 |
} |
| 101 | 101 |
|
| 102 |
-void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue) |
|
| 102 |
+void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue) |
|
| 103 | 103 |
{
|
| 104 | 104 |
FfmpegDiracSchroQueueElement *top = queue->p_head; |
| 105 | 105 |
|
| ... | ... |
@@ -107,7 +105,7 @@ void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue) |
| 107 | 107 |
void *data = top->data; |
| 108 | 108 |
queue->p_head = queue->p_head->next; |
| 109 | 109 |
--queue->size; |
| 110 |
- av_freep (&top); |
|
| 110 |
+ av_freep(&top); |
|
| 111 | 111 |
return data; |
| 112 | 112 |
} |
| 113 | 113 |
|
| ... | ... |
@@ -28,8 +28,7 @@ |
| 28 | 28 |
|
| 29 | 29 |
#include "avcodec.h" |
| 30 | 30 |
|
| 31 |
-typedef struct |
|
| 32 |
-{
|
|
| 31 |
+typedef struct {
|
|
| 33 | 32 |
uint16_t width; |
| 34 | 33 |
uint16_t height; |
| 35 | 34 |
uint16_t frame_rate_num; |
| ... | ... |
@@ -39,13 +38,12 @@ typedef struct |
| 39 | 39 |
/** |
| 40 | 40 |
* Returns the index into the Dirac Schro common video format info table |
| 41 | 41 |
*/ |
| 42 |
-unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext); |
|
| 42 |
+unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext); |
|
| 43 | 43 |
|
| 44 | 44 |
/** |
| 45 | 45 |
* contains a single encoded frame returned from Dirac or Schroedinger |
| 46 | 46 |
*/ |
| 47 |
-typedef struct FfmpegDiracSchroEncodedFrame |
|
| 48 |
-{
|
|
| 47 |
+typedef struct FfmpegDiracSchroEncodedFrame {
|
|
| 49 | 48 |
/** encoded frame data */ |
| 50 | 49 |
uint8_t *p_encbuf; |
| 51 | 50 |
|
| ... | ... |
@@ -62,8 +60,7 @@ typedef struct FfmpegDiracSchroEncodedFrame |
| 62 | 62 |
/** |
| 63 | 63 |
* queue element |
| 64 | 64 |
*/ |
| 65 |
-typedef struct FfmpegDiracSchroQueueElement |
|
| 66 |
-{
|
|
| 65 |
+typedef struct FfmpegDiracSchroQueueElement {
|
|
| 67 | 66 |
/** Data to be stored in queue*/ |
| 68 | 67 |
void *data; |
| 69 | 68 |
/** Pointer to next element queue */ |
| ... | ... |
@@ -74,8 +71,7 @@ typedef struct FfmpegDiracSchroQueueElement |
| 74 | 74 |
/** |
| 75 | 75 |
* A simple queue implementation used in libdirac and libschroedinger |
| 76 | 76 |
*/ |
| 77 |
-typedef struct FfmpegDiracSchroQueue |
|
| 78 |
-{
|
|
| 77 |
+typedef struct FfmpegDiracSchroQueue {
|
|
| 79 | 78 |
/** Pointer to head of queue */ |
| 80 | 79 |
FfmpegDiracSchroQueueElement *p_head; |
| 81 | 80 |
/** Pointer to tail of queue */ |
| ... | ... |
@@ -92,12 +88,12 @@ void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue); |
| 92 | 92 |
/** |
| 93 | 93 |
* Add an element to the end of the queue |
| 94 | 94 |
*/ |
| 95 |
-int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data); |
|
| 95 |
+int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data); |
|
| 96 | 96 |
|
| 97 | 97 |
/** |
| 98 | 98 |
* Return the first element in the queue |
| 99 | 99 |
*/ |
| 100 |
-void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue); |
|
| 100 |
+void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue); |
|
| 101 | 101 |
|
| 102 | 102 |
/** |
| 103 | 103 |
* Free the queue resources. free_func is a function supplied by the caller to |
| ... | ... |
@@ -36,8 +36,7 @@ |
| 36 | 36 |
#include <libdirac_decoder/dirac_parser.h> |
| 37 | 37 |
|
| 38 | 38 |
/** contains a single frame returned from Dirac */ |
| 39 |
-typedef struct FfmpegDiracDecoderParams |
|
| 40 |
-{
|
|
| 39 |
+typedef struct FfmpegDiracDecoderParams {
|
|
| 41 | 40 |
/** decoder handle */ |
| 42 | 41 |
dirac_decoder_t* p_decoder; |
| 43 | 42 |
|
| ... | ... |
@@ -64,13 +63,13 @@ static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt) |
| 64 | 64 |
static av_cold int libdirac_decode_init(AVCodecContext *avccontext) |
| 65 | 65 |
{
|
| 66 | 66 |
|
| 67 |
- FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data ; |
|
| 67 |
+ FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; |
|
| 68 | 68 |
p_dirac_params->p_decoder = dirac_decoder_init(avccontext->debug); |
| 69 | 69 |
|
| 70 | 70 |
if (!p_dirac_params->p_decoder) |
| 71 | 71 |
return -1; |
| 72 | 72 |
|
| 73 |
- return 0 ; |
|
| 73 |
+ return 0; |
|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 | 76 |
static int libdirac_decode_frame(AVCodecContext *avccontext, |
| ... | ... |
@@ -88,25 +87,23 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, |
| 88 | 88 |
|
| 89 | 89 |
*data_size = 0; |
| 90 | 90 |
|
| 91 |
- if (buf_size>0) {
|
|
| 91 |
+ if (buf_size > 0) {
|
|
| 92 | 92 |
/* set data to decode into buffer */ |
| 93 |
- dirac_buffer (p_dirac_params->p_decoder, buf, buf+buf_size); |
|
| 94 |
- if ((buf[4] &0x08) == 0x08 && (buf[4] & 0x03)) |
|
| 93 |
+ dirac_buffer(p_dirac_params->p_decoder, buf, buf + buf_size); |
|
| 94 |
+ if ((buf[4] & 0x08) == 0x08 && (buf[4] & 0x03)) |
|
| 95 | 95 |
avccontext->has_b_frames = 1; |
| 96 | 96 |
} |
| 97 | 97 |
while (1) {
|
| 98 | 98 |
/* parse data and process result */ |
| 99 |
- DecoderState state = dirac_parse (p_dirac_params->p_decoder); |
|
| 100 |
- switch (state) |
|
| 101 |
- {
|
|
| 99 |
+ DecoderState state = dirac_parse(p_dirac_params->p_decoder); |
|
| 100 |
+ switch (state) {
|
|
| 102 | 101 |
case STATE_BUFFER: |
| 103 | 102 |
return buf_size; |
| 104 | 103 |
|
| 105 | 104 |
case STATE_SEQUENCE: |
| 106 | 105 |
{
|
| 107 | 106 |
/* tell FFmpeg about sequence details */ |
| 108 |
- dirac_sourceparams_t *src_params = |
|
| 109 |
- &p_dirac_params->p_decoder->src_params; |
|
| 107 |
+ dirac_sourceparams_t *src_params = &p_dirac_params->p_decoder->src_params; |
|
| 110 | 108 |
|
| 111 | 109 |
if (avcodec_check_dimensions(avccontext, src_params->width, |
| 112 | 110 |
src_params->height) < 0) {
|
| ... | ... |
@@ -121,9 +118,9 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, |
| 121 | 121 |
|
| 122 | 122 |
avccontext->pix_fmt = GetFfmpegChromaFormat(src_params->chroma); |
| 123 | 123 |
if (avccontext->pix_fmt == PIX_FMT_NONE) {
|
| 124 |
- av_log (avccontext, AV_LOG_ERROR, |
|
| 125 |
- "Dirac chroma format %d not supported currently\n", |
|
| 126 |
- src_params->chroma); |
|
| 124 |
+ av_log(avccontext, AV_LOG_ERROR, |
|
| 125 |
+ "Dirac chroma format %d not supported currently\n", |
|
| 126 |
+ src_params->chroma); |
|
| 127 | 127 |
return -1; |
| 128 | 128 |
} |
| 129 | 129 |
|
| ... | ... |
@@ -140,7 +137,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, |
| 140 | 140 |
|
| 141 | 141 |
/* allocate output buffer */ |
| 142 | 142 |
if (!p_dirac_params->p_out_frame_buf) |
| 143 |
- p_dirac_params->p_out_frame_buf = av_malloc (pict_size); |
|
| 143 |
+ p_dirac_params->p_out_frame_buf = av_malloc(pict_size); |
|
| 144 | 144 |
buffer[0] = p_dirac_params->p_out_frame_buf; |
| 145 | 145 |
buffer[1] = p_dirac_params->p_out_frame_buf + |
| 146 | 146 |
pic.linesize[0] * avccontext->height; |
| ... | ... |
@@ -177,20 +174,20 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, |
| 177 | 177 |
static av_cold int libdirac_decode_close(AVCodecContext *avccontext) |
| 178 | 178 |
{
|
| 179 | 179 |
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; |
| 180 |
- dirac_decoder_close (p_dirac_params->p_decoder); |
|
| 180 |
+ dirac_decoder_close(p_dirac_params->p_decoder); |
|
| 181 | 181 |
|
| 182 | 182 |
av_freep(&p_dirac_params->p_out_frame_buf); |
| 183 | 183 |
|
| 184 |
- return 0 ; |
|
| 184 |
+ return 0; |
|
| 185 | 185 |
} |
| 186 | 186 |
|
| 187 |
-static void libdirac_flush (AVCodecContext *avccontext) |
|
| 187 |
+static void libdirac_flush(AVCodecContext *avccontext) |
|
| 188 | 188 |
{
|
| 189 | 189 |
/* Got a seek request. We will need free memory held in the private |
| 190 | 190 |
* context and free the current Dirac decoder handle and then open |
| 191 | 191 |
* a new decoder handle. */ |
| 192 |
- libdirac_decode_close (avccontext); |
|
| 193 |
- libdirac_decode_init (avccontext); |
|
| 192 |
+ libdirac_decode_close(avccontext); |
|
| 193 |
+ libdirac_decode_init(avccontext); |
|
| 194 | 194 |
return; |
| 195 | 195 |
} |
| 196 | 196 |
|
| ... | ... |
@@ -208,4 +205,4 @@ AVCodec libdirac_decoder = {
|
| 208 | 208 |
CODEC_CAP_DELAY, |
| 209 | 209 |
.flush = libdirac_flush, |
| 210 | 210 |
.long_name = NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"),
|
| 211 |
-} ; |
|
| 211 |
+}; |
| ... | ... |
@@ -38,8 +38,7 @@ |
| 38 | 38 |
#include <libdirac_encoder/dirac_encoder.h> |
| 39 | 39 |
|
| 40 | 40 |
/** Dirac encoder private data */ |
| 41 |
-typedef struct FfmpegDiracEncoderParams |
|
| 42 |
-{
|
|
| 41 |
+typedef struct FfmpegDiracEncoderParams {
|
|
| 43 | 42 |
/** Dirac encoder context */ |
| 44 | 43 |
dirac_encoder_context_t enc_ctx; |
| 45 | 44 |
|
| ... | ... |
@@ -114,12 +113,12 @@ static const VideoFormat ff_dirac_video_formats[]={
|
| 114 | 114 |
* Returns the video format preset matching the input video dimensions and |
| 115 | 115 |
* time base. |
| 116 | 116 |
*/ |
| 117 |
-static VideoFormat GetDiracVideoFormatPreset (AVCodecContext *avccontext) |
|
| 117 |
+static VideoFormat GetDiracVideoFormatPreset(AVCodecContext *avccontext) |
|
| 118 | 118 |
{
|
| 119 | 119 |
unsigned int num_formats = sizeof(ff_dirac_video_formats) / |
| 120 | 120 |
sizeof(ff_dirac_video_formats[0]); |
| 121 | 121 |
|
| 122 |
- unsigned int idx = ff_dirac_schro_get_video_format_idx (avccontext); |
|
| 122 |
+ unsigned int idx = ff_dirac_schro_get_video_format_idx(avccontext); |
|
| 123 | 123 |
|
| 124 | 124 |
return (idx < num_formats) ? |
| 125 | 125 |
ff_dirac_video_formats[idx] : VIDEO_FORMAT_CUSTOM; |
| ... | ... |
@@ -130,30 +129,27 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext) |
| 130 | 130 |
|
| 131 | 131 |
FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; |
| 132 | 132 |
int no_local = 1; |
| 133 |
- int verbose = avccontext->debug; |
|
| 133 |
+ int verbose = avccontext->debug; |
|
| 134 | 134 |
VideoFormat preset; |
| 135 | 135 |
|
| 136 | 136 |
/* get Dirac preset */ |
| 137 | 137 |
preset = GetDiracVideoFormatPreset(avccontext); |
| 138 | 138 |
|
| 139 | 139 |
/* initialize the encoder context */ |
| 140 |
- dirac_encoder_context_init (&(p_dirac_params->enc_ctx), preset); |
|
| 140 |
+ dirac_encoder_context_init(&(p_dirac_params->enc_ctx), preset); |
|
| 141 | 141 |
|
| 142 |
- p_dirac_params->enc_ctx.src_params.chroma = |
|
| 143 |
- GetDiracChromaFormat(avccontext->pix_fmt); |
|
| 142 |
+ p_dirac_params->enc_ctx.src_params.chroma = GetDiracChromaFormat(avccontext->pix_fmt); |
|
| 144 | 143 |
|
| 145 | 144 |
if (p_dirac_params->enc_ctx.src_params.chroma == formatNK) {
|
| 146 |
- av_log (avccontext, AV_LOG_ERROR, |
|
| 147 |
- "Unsupported pixel format %d. This codec supports only " |
|
| 148 |
- "Planar YUV formats (yuv420p, yuv422p, yuv444p\n", |
|
| 149 |
- avccontext->pix_fmt); |
|
| 145 |
+ av_log(avccontext, AV_LOG_ERROR, |
|
| 146 |
+ "Unsupported pixel format %d. This codec supports only " |
|
| 147 |
+ "Planar YUV formats (yuv420p, yuv422p, yuv444p\n", |
|
| 148 |
+ avccontext->pix_fmt); |
|
| 150 | 149 |
return -1; |
| 151 | 150 |
} |
| 152 | 151 |
|
| 153 |
- p_dirac_params->enc_ctx.src_params.frame_rate.numerator = |
|
| 154 |
- avccontext->time_base.den; |
|
| 155 |
- p_dirac_params->enc_ctx.src_params.frame_rate.denominator = |
|
| 156 |
- avccontext->time_base.num; |
|
| 152 |
+ p_dirac_params->enc_ctx.src_params.frame_rate.numerator = avccontext->time_base.den; |
|
| 153 |
+ p_dirac_params->enc_ctx.src_params.frame_rate.denominator = avccontext->time_base.num; |
|
| 157 | 154 |
|
| 158 | 155 |
p_dirac_params->enc_ctx.src_params.width = avccontext->width; |
| 159 | 156 |
p_dirac_params->enc_ctx.src_params.height = avccontext->height; |
| ... | ... |
@@ -182,20 +178,20 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext) |
| 182 | 182 |
|
| 183 | 183 |
if (avccontext->flags & CODEC_FLAG_QSCALE) {
|
| 184 | 184 |
if (avccontext->global_quality) {
|
| 185 |
- p_dirac_params->enc_ctx.enc_params.qf = |
|
| 186 |
- avccontext->global_quality / (FF_QP2LAMBDA*10.0); |
|
| 185 |
+ p_dirac_params->enc_ctx.enc_params.qf = avccontext->global_quality |
|
| 186 |
+ / (FF_QP2LAMBDA * 10.0); |
|
| 187 | 187 |
/* if it is not default bitrate then send target rate. */ |
| 188 | 188 |
if (avccontext->bit_rate >= 1000 && |
| 189 | 189 |
avccontext->bit_rate != 200000) |
| 190 |
- p_dirac_params->enc_ctx.enc_params.trate = |
|
| 191 |
- avccontext->bit_rate / 1000; |
|
| 190 |
+ p_dirac_params->enc_ctx.enc_params.trate = avccontext->bit_rate |
|
| 191 |
+ / 1000; |
|
| 192 | 192 |
} else |
| 193 | 193 |
p_dirac_params->enc_ctx.enc_params.lossless = 1; |
| 194 | 194 |
} else if (avccontext->bit_rate >= 1000) |
| 195 | 195 |
p_dirac_params->enc_ctx.enc_params.trate = avccontext->bit_rate / 1000; |
| 196 | 196 |
|
| 197 | 197 |
if ((preset > VIDEO_FORMAT_QCIF || preset < VIDEO_FORMAT_QSIF525) && |
| 198 |
- avccontext->bit_rate == 200000) |
|
| 198 |
+ avccontext->bit_rate == 200000) |
|
| 199 | 199 |
p_dirac_params->enc_ctx.enc_params.trate = 0; |
| 200 | 200 |
|
| 201 | 201 |
if (avccontext->flags & CODEC_FLAG_INTERLACED_ME) |
| ... | ... |
@@ -203,8 +199,8 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext) |
| 203 | 203 |
* irrespective of the type of source material */ |
| 204 | 204 |
p_dirac_params->enc_ctx.enc_params.picture_coding_mode = 1; |
| 205 | 205 |
|
| 206 |
- p_dirac_params->p_encoder = dirac_encoder_init (&(p_dirac_params->enc_ctx), |
|
| 207 |
- verbose ); |
|
| 206 |
+ p_dirac_params->p_encoder = dirac_encoder_init(&(p_dirac_params->enc_ctx), |
|
| 207 |
+ verbose); |
|
| 208 | 208 |
|
| 209 | 209 |
if (!p_dirac_params->p_encoder) {
|
| 210 | 210 |
av_log(avccontext, AV_LOG_ERROR, |
| ... | ... |
@@ -218,14 +214,14 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext) |
| 218 | 218 |
/* initialize the encoded frame queue */ |
| 219 | 219 |
ff_dirac_schro_queue_init(&p_dirac_params->enc_frame_queue); |
| 220 | 220 |
|
| 221 |
- return 0 ; |
|
| 221 |
+ return 0; |
|
| 222 | 222 |
} |
| 223 | 223 |
|
| 224 |
-static void DiracFreeFrame (void *data) |
|
| 224 |
+static void DiracFreeFrame(void *data) |
|
| 225 | 225 |
{
|
| 226 | 226 |
FfmpegDiracSchroEncodedFrame *enc_frame = data; |
| 227 | 227 |
|
| 228 |
- av_freep (&(enc_frame->p_encbuf)); |
|
| 228 |
+ av_freep(&(enc_frame->p_encbuf)); |
|
| 229 | 229 |
av_free(enc_frame); |
| 230 | 230 |
} |
| 231 | 231 |
|
| ... | ... |
@@ -236,7 +232,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 236 | 236 |
int enc_size = 0; |
| 237 | 237 |
dirac_encoder_state_t state; |
| 238 | 238 |
FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; |
| 239 |
- FfmpegDiracSchroEncodedFrame* p_frame_output = NULL; |
|
| 239 |
+ FfmpegDiracSchroEncodedFrame* p_frame_output = NULL; |
|
| 240 | 240 |
FfmpegDiracSchroEncodedFrame* p_next_output_frame = NULL; |
| 241 | 241 |
int go = 1; |
| 242 | 242 |
int last_frame_in_sequence = 0; |
| ... | ... |
@@ -244,7 +240,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 244 | 244 |
if (!data) {
|
| 245 | 245 |
/* push end of sequence if not already signalled */ |
| 246 | 246 |
if (!p_dirac_params->eos_signalled) {
|
| 247 |
- dirac_encoder_end_sequence( p_dirac_params->p_encoder ); |
|
| 247 |
+ dirac_encoder_end_sequence(p_dirac_params->p_encoder); |
|
| 248 | 248 |
p_dirac_params->eos_signalled = 1; |
| 249 | 249 |
} |
| 250 | 250 |
} else {
|
| ... | ... |
@@ -253,15 +249,15 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 253 | 253 |
* Input line size may differ from what the codec supports, |
| 254 | 254 |
* especially when transcoding from one format to another. |
| 255 | 255 |
* So use avpicture_layout to copy the frame. */ |
| 256 |
- avpicture_layout ((AVPicture *)data, avccontext->pix_fmt, |
|
| 257 |
- avccontext->width, avccontext->height, |
|
| 258 |
- p_dirac_params->p_in_frame_buf, |
|
| 259 |
- p_dirac_params->frame_size); |
|
| 256 |
+ avpicture_layout((AVPicture *)data, avccontext->pix_fmt, |
|
| 257 |
+ avccontext->width, avccontext->height, |
|
| 258 |
+ p_dirac_params->p_in_frame_buf, |
|
| 259 |
+ p_dirac_params->frame_size); |
|
| 260 | 260 |
|
| 261 | 261 |
/* load next frame */ |
| 262 |
- if (dirac_encoder_load (p_dirac_params->p_encoder, |
|
| 263 |
- p_dirac_params->p_in_frame_buf, |
|
| 264 |
- p_dirac_params->frame_size ) < 0) {
|
|
| 262 |
+ if (dirac_encoder_load(p_dirac_params->p_encoder, |
|
| 263 |
+ p_dirac_params->p_in_frame_buf, |
|
| 264 |
+ p_dirac_params->frame_size) < 0) {
|
|
| 265 | 265 |
av_log(avccontext, AV_LOG_ERROR, "Unrecoverable Encoder Error." |
| 266 | 266 |
" dirac_encoder_load failed...\n"); |
| 267 | 267 |
return -1; |
| ... | ... |
@@ -271,34 +267,30 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 271 | 271 |
if (p_dirac_params->eos_pulled) |
| 272 | 272 |
go = 0; |
| 273 | 273 |
|
| 274 |
- while(go) {
|
|
| 274 |
+ while (go) {
|
|
| 275 | 275 |
p_dirac_params->p_encoder->enc_buf.buffer = frame; |
| 276 | 276 |
p_dirac_params->p_encoder->enc_buf.size = buf_size; |
| 277 | 277 |
/* process frame */ |
| 278 |
- state = dirac_encoder_output ( p_dirac_params->p_encoder ); |
|
| 278 |
+ state = dirac_encoder_output(p_dirac_params->p_encoder); |
|
| 279 | 279 |
|
| 280 |
- switch (state) |
|
| 281 |
- {
|
|
| 280 |
+ switch (state) {
|
|
| 282 | 281 |
case ENC_STATE_AVAIL: |
| 283 | 282 |
case ENC_STATE_EOS: |
| 284 |
- assert (p_dirac_params->p_encoder->enc_buf.size > 0); |
|
| 283 |
+ assert(p_dirac_params->p_encoder->enc_buf.size > 0); |
|
| 285 | 284 |
|
| 286 | 285 |
/* All non-frame data is prepended to actual frame data to |
| 287 | 286 |
* be able to set the pts correctly. So we don't write data |
| 288 | 287 |
* to the frame output queue until we actually have a frame |
| 289 | 288 |
*/ |
| 290 | 289 |
|
| 291 |
- p_dirac_params->enc_buf = av_realloc ( |
|
| 292 |
- p_dirac_params->enc_buf, |
|
| 293 |
- p_dirac_params->enc_buf_size + |
|
| 294 |
- p_dirac_params->p_encoder->enc_buf.size |
|
| 295 |
- ); |
|
| 290 |
+ p_dirac_params->enc_buf = av_realloc(p_dirac_params->enc_buf, |
|
| 291 |
+ p_dirac_params->enc_buf_size + |
|
| 292 |
+ p_dirac_params->p_encoder->enc_buf.size); |
|
| 296 | 293 |
memcpy(p_dirac_params->enc_buf + p_dirac_params->enc_buf_size, |
| 297 | 294 |
p_dirac_params->p_encoder->enc_buf.buffer, |
| 298 | 295 |
p_dirac_params->p_encoder->enc_buf.size); |
| 299 | 296 |
|
| 300 |
- p_dirac_params->enc_buf_size += |
|
| 301 |
- p_dirac_params->p_encoder->enc_buf.size; |
|
| 297 |
+ p_dirac_params->enc_buf_size += p_dirac_params->p_encoder->enc_buf.size; |
|
| 302 | 298 |
|
| 303 | 299 |
if (state == ENC_STATE_EOS) {
|
| 304 | 300 |
p_dirac_params->eos_pulled = 1; |
| ... | ... |
@@ -313,17 +305,16 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 313 | 313 |
/* create output frame */ |
| 314 | 314 |
p_frame_output = av_mallocz(sizeof(FfmpegDiracSchroEncodedFrame)); |
| 315 | 315 |
/* set output data */ |
| 316 |
- p_frame_output->size = p_dirac_params->enc_buf_size; |
|
| 317 |
- p_frame_output->p_encbuf = p_dirac_params->enc_buf; |
|
| 318 |
- p_frame_output->frame_num = |
|
| 319 |
- p_dirac_params->p_encoder->enc_pparams.pnum; |
|
| 316 |
+ p_frame_output->size = p_dirac_params->enc_buf_size; |
|
| 317 |
+ p_frame_output->p_encbuf = p_dirac_params->enc_buf; |
|
| 318 |
+ p_frame_output->frame_num = p_dirac_params->p_encoder->enc_pparams.pnum; |
|
| 320 | 319 |
|
| 321 | 320 |
if (p_dirac_params->p_encoder->enc_pparams.ptype == INTRA_PICTURE && |
| 322 | 321 |
p_dirac_params->p_encoder->enc_pparams.rtype == REFERENCE_PICTURE) |
| 323 | 322 |
p_frame_output->key_frame = 1; |
| 324 | 323 |
|
| 325 |
- ff_dirac_schro_queue_push_back (&p_dirac_params->enc_frame_queue, |
|
| 326 |
- p_frame_output); |
|
| 324 |
+ ff_dirac_schro_queue_push_back(&p_dirac_params->enc_frame_queue, |
|
| 325 |
+ p_frame_output); |
|
| 327 | 326 |
|
| 328 | 327 |
p_dirac_params->enc_buf_size = 0; |
| 329 | 328 |
p_dirac_params->enc_buf = NULL; |
| ... | ... |
@@ -346,12 +337,10 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 346 | 346 |
|
| 347 | 347 |
/* copy 'next' frame in queue */ |
| 348 | 348 |
|
| 349 |
- if (p_dirac_params->enc_frame_queue.size == 1 && |
|
| 350 |
- p_dirac_params->eos_pulled) |
|
| 349 |
+ if (p_dirac_params->enc_frame_queue.size == 1 && p_dirac_params->eos_pulled) |
|
| 351 | 350 |
last_frame_in_sequence = 1; |
| 352 | 351 |
|
| 353 |
- p_next_output_frame = |
|
| 354 |
- ff_dirac_schro_queue_pop(&p_dirac_params->enc_frame_queue); |
|
| 352 |
+ p_next_output_frame = ff_dirac_schro_queue_pop(&p_dirac_params->enc_frame_queue); |
|
| 355 | 353 |
|
| 356 | 354 |
if (!p_next_output_frame) |
| 357 | 355 |
return 0; |
| ... | ... |
@@ -366,12 +355,11 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 366 | 366 |
|
| 367 | 367 |
/* Append the end of sequence information to the last frame in the |
| 368 | 368 |
* sequence. */ |
| 369 |
- if (last_frame_in_sequence && p_dirac_params->enc_buf_size > 0) |
|
| 370 |
- {
|
|
| 371 |
- memcpy (frame + enc_size, p_dirac_params->enc_buf, |
|
| 372 |
- p_dirac_params->enc_buf_size); |
|
| 369 |
+ if (last_frame_in_sequence && p_dirac_params->enc_buf_size > 0) {
|
|
| 370 |
+ memcpy(frame + enc_size, p_dirac_params->enc_buf, |
|
| 371 |
+ p_dirac_params->enc_buf_size); |
|
| 373 | 372 |
enc_size += p_dirac_params->enc_buf_size; |
| 374 |
- av_freep (&p_dirac_params->enc_buf); |
|
| 373 |
+ av_freep(&p_dirac_params->enc_buf); |
|
| 375 | 374 |
p_dirac_params->enc_buf_size = 0; |
| 376 | 375 |
} |
| 377 | 376 |
|
| ... | ... |
@@ -386,7 +374,7 @@ static av_cold int libdirac_encode_close(AVCodecContext *avccontext) |
| 386 | 386 |
FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; |
| 387 | 387 |
|
| 388 | 388 |
/* close the encoder */ |
| 389 |
- dirac_encoder_close(p_dirac_params->p_encoder ); |
|
| 389 |
+ dirac_encoder_close(p_dirac_params->p_encoder); |
|
| 390 | 390 |
|
| 391 | 391 |
/* free data in the output frame queue */ |
| 392 | 392 |
ff_dirac_schro_queue_free(&p_dirac_params->enc_frame_queue, |
| ... | ... |
@@ -399,7 +387,7 @@ static av_cold int libdirac_encode_close(AVCodecContext *avccontext) |
| 399 | 399 |
/* free the input frame buffer */ |
| 400 | 400 |
av_freep(&p_dirac_params->p_in_frame_buf); |
| 401 | 401 |
|
| 402 |
- return 0 ; |
|
| 402 |
+ return 0; |
|
| 403 | 403 |
} |
| 404 | 404 |
|
| 405 | 405 |
|
| ... | ... |
@@ -411,7 +399,7 @@ AVCodec libdirac_encoder = {
|
| 411 | 411 |
libdirac_encode_init, |
| 412 | 412 |
libdirac_encode_frame, |
| 413 | 413 |
libdirac_encode_close, |
| 414 |
- .capabilities= CODEC_CAP_DELAY, |
|
| 415 |
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_NONE},
|
|
| 416 |
- .long_name= NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"),
|
|
| 417 |
-} ; |
|
| 414 |
+ .capabilities = CODEC_CAP_DELAY, |
|
| 415 |
+ .pix_fmts = (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_NONE},
|
|
| 416 |
+ .long_name = NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"),
|
|
| 417 |
+}; |
| ... | ... |
@@ -57,8 +57,8 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avccontext |
| 57 | 57 |
|
| 58 | 58 |
unsigned int idx = ff_dirac_schro_get_video_format_idx (avccontext); |
| 59 | 59 |
|
| 60 |
- return (idx < num_formats) ? |
|
| 61 |
- ff_schro_video_formats[idx] : SCHRO_VIDEO_FORMAT_CUSTOM; |
|
| 60 |
+ return (idx < num_formats) ? ff_schro_video_formats[idx] : |
|
| 61 |
+ SCHRO_VIDEO_FORMAT_CUSTOM; |
|
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt, |
| ... | ... |
@@ -71,8 +71,7 @@ int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt, |
| 71 | 71 |
|
| 72 | 72 |
for (idx = 0; idx < num_formats; ++idx) {
|
| 73 | 73 |
if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
|
| 74 |
- *schro_frame_fmt = |
|
| 75 |
- ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt; |
|
| 74 |
+ *schro_frame_fmt = ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt; |
|
| 76 | 75 |
return 0; |
| 77 | 76 |
} |
| 78 | 77 |
} |
| ... | ... |
@@ -50,7 +50,7 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset (AVCodecContext *avccontex |
| 50 | 50 |
* Sets the Schroedinger frame format corresponding to the Schro chroma format |
| 51 | 51 |
* passed. Returns 0 on success, -1 on failure. |
| 52 | 52 |
*/ |
| 53 |
-int ff_get_schro_frame_format (SchroChromaFormat schro_chroma_fmt, |
|
| 54 |
- SchroFrameFormat *schro_frame_fmt); |
|
| 53 |
+int ff_get_schro_frame_format(SchroChromaFormat schro_chroma_fmt, |
|
| 54 |
+ SchroFrameFormat *schro_frame_fmt); |
|
| 55 | 55 |
|
| 56 | 56 |
#endif /* AVCODEC_LIBSCHROEDINGER_H */ |
| ... | ... |
@@ -40,8 +40,7 @@ |
| 40 | 40 |
#include <schroedinger/schrovideoformat.h> |
| 41 | 41 |
|
| 42 | 42 |
/** libschroedinger decoder private data */ |
| 43 |
-typedef struct FfmpegSchroDecoderParams |
|
| 44 |
-{
|
|
| 43 |
+typedef struct FfmpegSchroDecoderParams {
|
|
| 45 | 44 |
/** Schroedinger video format */ |
| 46 | 45 |
SchroVideoFormat *format; |
| 47 | 46 |
|
| ... | ... |
@@ -64,24 +63,23 @@ typedef struct FfmpegSchroDecoderParams |
| 64 | 64 |
AVPicture dec_pic; |
| 65 | 65 |
} FfmpegSchroDecoderParams; |
| 66 | 66 |
|
| 67 |
-typedef struct FfmpegSchroParseUnitContext |
|
| 68 |
-{
|
|
| 67 |
+typedef struct FfmpegSchroParseUnitContext {
|
|
| 69 | 68 |
const uint8_t *buf; |
| 70 | 69 |
int buf_size; |
| 71 | 70 |
} FfmpegSchroParseUnitContext; |
| 72 | 71 |
|
| 73 | 72 |
|
| 74 |
-static void libschroedinger_decode_buffer_free (SchroBuffer *schro_buf, |
|
| 75 |
- void *priv); |
|
| 73 |
+static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, |
|
| 74 |
+ void *priv); |
|
| 76 | 75 |
|
| 77 |
-static void FfmpegSchroParseContextInit (FfmpegSchroParseUnitContext *parse_ctx, |
|
| 78 |
- const uint8_t *buf, int buf_size) |
|
| 76 |
+static void FfmpegSchroParseContextInit(FfmpegSchroParseUnitContext *parse_ctx, |
|
| 77 |
+ const uint8_t *buf, int buf_size) |
|
| 79 | 78 |
{
|
| 80 | 79 |
parse_ctx->buf = buf; |
| 81 | 80 |
parse_ctx->buf_size = buf_size; |
| 82 | 81 |
} |
| 83 | 82 |
|
| 84 |
-static SchroBuffer* FfmpegFindNextSchroParseUnit (FfmpegSchroParseUnitContext *parse_ctx) |
|
| 83 |
+static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *parse_ctx) |
|
| 85 | 84 |
{
|
| 86 | 85 |
SchroBuffer *enc_buf = NULL; |
| 87 | 86 |
int next_pu_offset = 0; |
| ... | ... |
@@ -107,12 +105,12 @@ static SchroBuffer* FfmpegFindNextSchroParseUnit (FfmpegSchroParseUnitContext *p |
| 107 | 107 |
return NULL; |
| 108 | 108 |
|
| 109 | 109 |
in_buf = av_malloc(next_pu_offset); |
| 110 |
- memcpy (in_buf, parse_ctx->buf, next_pu_offset); |
|
| 111 |
- enc_buf = schro_buffer_new_with_data (in_buf, next_pu_offset); |
|
| 110 |
+ memcpy(in_buf, parse_ctx->buf, next_pu_offset); |
|
| 111 |
+ enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset); |
|
| 112 | 112 |
enc_buf->free = libschroedinger_decode_buffer_free; |
| 113 | 113 |
enc_buf->priv = in_buf; |
| 114 | 114 |
|
| 115 |
- parse_ctx->buf += next_pu_offset; |
|
| 115 |
+ parse_ctx->buf += next_pu_offset; |
|
| 116 | 116 |
parse_ctx->buf_size -= next_pu_offset; |
| 117 | 117 |
|
| 118 | 118 |
return enc_buf; |
| ... | ... |
@@ -136,29 +134,29 @@ static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt) |
| 136 | 136 |
static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext) |
| 137 | 137 |
{
|
| 138 | 138 |
|
| 139 |
- FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data ; |
|
| 139 |
+ FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 140 | 140 |
/* First of all, initialize our supporting libraries. */ |
| 141 | 141 |
schro_init(); |
| 142 | 142 |
|
| 143 | 143 |
schro_debug_set_level(avccontext->debug); |
| 144 |
- p_schro_params->decoder = schro_decoder_new(); |
|
| 144 |
+ p_schro_params->decoder = schro_decoder_new(); |
|
| 145 | 145 |
schro_decoder_set_skip_ratio(p_schro_params->decoder, 1); |
| 146 | 146 |
|
| 147 | 147 |
if (!p_schro_params->decoder) |
| 148 | 148 |
return -1; |
| 149 | 149 |
|
| 150 | 150 |
/* Initialize the decoded frame queue. */ |
| 151 |
- ff_dirac_schro_queue_init (&p_schro_params->dec_frame_queue); |
|
| 152 |
- return 0 ; |
|
| 151 |
+ ff_dirac_schro_queue_init(&p_schro_params->dec_frame_queue); |
|
| 152 |
+ return 0; |
|
| 153 | 153 |
} |
| 154 | 154 |
|
| 155 |
-static void libschroedinger_decode_buffer_free (SchroBuffer *schro_buf, |
|
| 156 |
- void *priv) |
|
| 155 |
+static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, |
|
| 156 |
+ void *priv) |
|
| 157 | 157 |
{
|
| 158 | 158 |
av_freep(&priv); |
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 |
-static void libschroedinger_decode_frame_free (void *frame) |
|
| 161 |
+static void libschroedinger_decode_frame_free(void *frame) |
|
| 162 | 162 |
{
|
| 163 | 163 |
schro_frame_unref(frame); |
| 164 | 164 |
} |
| ... | ... |
@@ -168,11 +166,11 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) |
| 168 | 168 |
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
| 169 | 169 |
SchroDecoder *decoder = p_schro_params->decoder; |
| 170 | 170 |
|
| 171 |
- p_schro_params->format = schro_decoder_get_video_format (decoder); |
|
| 171 |
+ p_schro_params->format = schro_decoder_get_video_format(decoder); |
|
| 172 | 172 |
|
| 173 | 173 |
/* Tell FFmpeg about sequence details. */ |
| 174 |
- if(avcodec_check_dimensions(avccontext, p_schro_params->format->width, |
|
| 175 |
- p_schro_params->format->height) < 0) {
|
|
| 174 |
+ if (avcodec_check_dimensions(avccontext, p_schro_params->format->width, |
|
| 175 |
+ p_schro_params->format->height) < 0) {
|
|
| 176 | 176 |
av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n", |
| 177 | 177 |
p_schro_params->format->width, p_schro_params->format->height); |
| 178 | 178 |
avccontext->height = avccontext->width = 0; |
| ... | ... |
@@ -180,14 +178,13 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) |
| 180 | 180 |
} |
| 181 | 181 |
avccontext->height = p_schro_params->format->height; |
| 182 | 182 |
avccontext->width = p_schro_params->format->width; |
| 183 |
- avccontext->pix_fmt = |
|
| 184 |
- GetFfmpegChromaFormat(p_schro_params->format->chroma_format); |
|
| 185 |
- |
|
| 186 |
- if (ff_get_schro_frame_format( p_schro_params->format->chroma_format, |
|
| 187 |
- &p_schro_params->frame_format) == -1) {
|
|
| 188 |
- av_log (avccontext, AV_LOG_ERROR, |
|
| 189 |
- "This codec currently only supports planar YUV 4:2:0, 4:2:2 " |
|
| 190 |
- "and 4:4:4 formats.\n"); |
|
| 183 |
+ avccontext->pix_fmt = GetFfmpegChromaFormat(p_schro_params->format->chroma_format); |
|
| 184 |
+ |
|
| 185 |
+ if (ff_get_schro_frame_format(p_schro_params->format->chroma_format, |
|
| 186 |
+ &p_schro_params->frame_format) == -1) {
|
|
| 187 |
+ av_log(avccontext, AV_LOG_ERROR, |
|
| 188 |
+ "This codec currently only supports planar YUV 4:2:0, 4:2:2 " |
|
| 189 |
+ "and 4:4:4 formats.\n"); |
|
| 191 | 190 |
return; |
| 192 | 191 |
} |
| 193 | 192 |
|
| ... | ... |
@@ -221,7 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, |
| 221 | 221 |
|
| 222 | 222 |
*data_size = 0; |
| 223 | 223 |
|
| 224 |
- FfmpegSchroParseContextInit (&parse_ctx, buf, buf_size); |
|
| 224 |
+ FfmpegSchroParseContextInit(&parse_ctx, buf, buf_size); |
|
| 225 | 225 |
if (!buf_size) {
|
| 226 | 226 |
if (!p_schro_params->eos_signalled) {
|
| 227 | 227 |
state = schro_decoder_push_end_of_stream(decoder); |
| ... | ... |
@@ -236,77 +233,74 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, |
| 236 | 236 |
if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) && |
| 237 | 237 |
SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0) |
| 238 | 238 |
avccontext->has_b_frames = 1; |
| 239 |
- state = schro_decoder_push (decoder, enc_buf); |
|
| 239 |
+ state = schro_decoder_push(decoder, enc_buf); |
|
| 240 | 240 |
if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT) |
| 241 |
- libschroedinger_handle_first_access_unit(avccontext); |
|
| 241 |
+ libschroedinger_handle_first_access_unit(avccontext); |
|
| 242 | 242 |
go = 1; |
| 243 |
- } |
|
| 244 |
- else |
|
| 245 |
- outer = 0; |
|
| 246 |
- format = p_schro_params->format; |
|
| 247 |
- |
|
| 248 |
- while (go) {
|
|
| 249 |
- /* Parse data and process result. */ |
|
| 250 |
- state = schro_decoder_wait (decoder); |
|
| 251 |
- switch (state) |
|
| 252 |
- {
|
|
| 253 |
- case SCHRO_DECODER_FIRST_ACCESS_UNIT: |
|
| 254 |
- libschroedinger_handle_first_access_unit (avccontext); |
|
| 255 |
- break; |
|
| 256 |
- |
|
| 257 |
- case SCHRO_DECODER_NEED_BITS: |
|
| 258 |
- /* Need more input data - stop iterating over what we have. */ |
|
| 259 |
- go = 0; |
|
| 260 |
- break; |
|
| 261 |
- |
|
| 262 |
- case SCHRO_DECODER_NEED_FRAME: |
|
| 263 |
- /* Decoder needs a frame - create one and push it in. */ |
|
| 264 |
- |
|
| 265 |
- frame = schro_frame_new_and_alloc(NULL, |
|
| 266 |
- p_schro_params->frame_format, |
|
| 267 |
- format->width, |
|
| 268 |
- format->height); |
|
| 269 |
- schro_decoder_add_output_picture (decoder, frame); |
|
| 270 |
- break; |
|
| 271 |
- |
|
| 272 |
- case SCHRO_DECODER_OK: |
|
| 273 |
- /* Pull a frame out of the decoder. */ |
|
| 274 |
- frame = schro_decoder_pull (decoder); |
|
| 275 |
- |
|
| 276 |
- if (frame) |
|
| 277 |
- ff_dirac_schro_queue_push_back( |
|
| 278 |
- &p_schro_params->dec_frame_queue, |
|
| 279 |
- frame); |
|
| 280 |
- break; |
|
| 281 |
- case SCHRO_DECODER_EOS: |
|
| 282 |
- go = 0; |
|
| 283 |
- p_schro_params->eos_pulled = 1; |
|
| 284 |
- schro_decoder_reset (decoder); |
|
| 243 |
+ } else |
|
| 285 | 244 |
outer = 0; |
| 286 |
- break; |
|
| 287 |
- |
|
| 288 |
- case SCHRO_DECODER_ERROR: |
|
| 289 |
- return -1; |
|
| 290 |
- break; |
|
| 245 |
+ format = p_schro_params->format; |
|
| 246 |
+ |
|
| 247 |
+ while (go) {
|
|
| 248 |
+ /* Parse data and process result. */ |
|
| 249 |
+ state = schro_decoder_wait(decoder); |
|
| 250 |
+ switch (state) {
|
|
| 251 |
+ case SCHRO_DECODER_FIRST_ACCESS_UNIT: |
|
| 252 |
+ libschroedinger_handle_first_access_unit(avccontext); |
|
| 253 |
+ break; |
|
| 254 |
+ |
|
| 255 |
+ case SCHRO_DECODER_NEED_BITS: |
|
| 256 |
+ /* Need more input data - stop iterating over what we have. */ |
|
| 257 |
+ go = 0; |
|
| 258 |
+ break; |
|
| 259 |
+ |
|
| 260 |
+ case SCHRO_DECODER_NEED_FRAME: |
|
| 261 |
+ /* Decoder needs a frame - create one and push it in. */ |
|
| 262 |
+ |
|
| 263 |
+ frame = schro_frame_new_and_alloc(NULL, |
|
| 264 |
+ p_schro_params->frame_format, |
|
| 265 |
+ format->width, |
|
| 266 |
+ format->height); |
|
| 267 |
+ schro_decoder_add_output_picture(decoder, frame); |
|
| 268 |
+ break; |
|
| 269 |
+ |
|
| 270 |
+ case SCHRO_DECODER_OK: |
|
| 271 |
+ /* Pull a frame out of the decoder. */ |
|
| 272 |
+ frame = schro_decoder_pull(decoder); |
|
| 273 |
+ |
|
| 274 |
+ if (frame) |
|
| 275 |
+ ff_dirac_schro_queue_push_back(&p_schro_params->dec_frame_queue, |
|
| 276 |
+ frame); |
|
| 277 |
+ break; |
|
| 278 |
+ case SCHRO_DECODER_EOS: |
|
| 279 |
+ go = 0; |
|
| 280 |
+ p_schro_params->eos_pulled = 1; |
|
| 281 |
+ schro_decoder_reset(decoder); |
|
| 282 |
+ outer = 0; |
|
| 283 |
+ break; |
|
| 284 |
+ |
|
| 285 |
+ case SCHRO_DECODER_ERROR: |
|
| 286 |
+ return -1; |
|
| 287 |
+ break; |
|
| 288 |
+ } |
|
| 291 | 289 |
} |
| 292 |
- } |
|
| 293 |
- } while(outer); |
|
| 290 |
+ } while (outer); |
|
| 294 | 291 |
|
| 295 | 292 |
/* Grab next frame to be returned from the top of the queue. */ |
| 296 | 293 |
frame = ff_dirac_schro_queue_pop(&p_schro_params->dec_frame_queue); |
| 297 | 294 |
|
| 298 | 295 |
if (frame) {
|
| 299 |
- memcpy (p_schro_params->dec_pic.data[0], |
|
| 300 |
- frame->components[0].data, |
|
| 301 |
- frame->components[0].length); |
|
| 296 |
+ memcpy(p_schro_params->dec_pic.data[0], |
|
| 297 |
+ frame->components[0].data, |
|
| 298 |
+ frame->components[0].length); |
|
| 302 | 299 |
|
| 303 |
- memcpy (p_schro_params->dec_pic.data[1], |
|
| 304 |
- frame->components[1].data, |
|
| 305 |
- frame->components[1].length); |
|
| 300 |
+ memcpy(p_schro_params->dec_pic.data[1], |
|
| 301 |
+ frame->components[1].data, |
|
| 302 |
+ frame->components[1].length); |
|
| 306 | 303 |
|
| 307 |
- memcpy (p_schro_params->dec_pic.data[2], |
|
| 308 |
- frame->components[2].data, |
|
| 309 |
- frame->components[2].length); |
|
| 304 |
+ memcpy(p_schro_params->dec_pic.data[2], |
|
| 305 |
+ frame->components[2].data, |
|
| 306 |
+ frame->components[2].length); |
|
| 310 | 307 |
|
| 311 | 308 |
/* Fill picture with current buffer data from Schroedinger. */ |
| 312 | 309 |
avpicture_fill(picture, p_schro_params->dec_pic.data[0], |
| ... | ... |
@@ -316,7 +310,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, |
| 316 | 316 |
*data_size = sizeof(AVPicture); |
| 317 | 317 |
|
| 318 | 318 |
/* Now free the frame resources. */ |
| 319 |
- libschroedinger_decode_frame_free (frame); |
|
| 319 |
+ libschroedinger_decode_frame_free(frame); |
|
| 320 | 320 |
} |
| 321 | 321 |
return buf_size; |
| 322 | 322 |
} |
| ... | ... |
@@ -326,36 +320,36 @@ static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext) |
| 326 | 326 |
{
|
| 327 | 327 |
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
| 328 | 328 |
/* Free the decoder. */ |
| 329 |
- schro_decoder_free (p_schro_params->decoder); |
|
| 329 |
+ schro_decoder_free(p_schro_params->decoder); |
|
| 330 | 330 |
av_freep(&p_schro_params->format); |
| 331 | 331 |
|
| 332 |
- avpicture_free (&p_schro_params->dec_pic); |
|
| 332 |
+ avpicture_free(&p_schro_params->dec_pic); |
|
| 333 | 333 |
|
| 334 | 334 |
/* Free data in the output frame queue. */ |
| 335 |
- ff_dirac_schro_queue_free (&p_schro_params->dec_frame_queue, |
|
| 336 |
- libschroedinger_decode_frame_free); |
|
| 335 |
+ ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue, |
|
| 336 |
+ libschroedinger_decode_frame_free); |
|
| 337 | 337 |
|
| 338 |
- return 0 ; |
|
| 338 |
+ return 0; |
|
| 339 | 339 |
} |
| 340 | 340 |
|
| 341 |
-static void libschroedinger_flush (AVCodecContext *avccontext) |
|
| 341 |
+static void libschroedinger_flush(AVCodecContext *avccontext) |
|
| 342 | 342 |
{
|
| 343 | 343 |
/* Got a seek request. Free the decoded frames queue and then reset |
| 344 | 344 |
* the decoder */ |
| 345 | 345 |
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
| 346 | 346 |
|
| 347 | 347 |
/* Free data in the output frame queue. */ |
| 348 |
- ff_dirac_schro_queue_free (&p_schro_params->dec_frame_queue, |
|
| 349 |
- libschroedinger_decode_frame_free); |
|
| 348 |
+ ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue, |
|
| 349 |
+ libschroedinger_decode_frame_free); |
|
| 350 | 350 |
|
| 351 |
- ff_dirac_schro_queue_init (&p_schro_params->dec_frame_queue); |
|
| 351 |
+ ff_dirac_schro_queue_init(&p_schro_params->dec_frame_queue); |
|
| 352 | 352 |
schro_decoder_reset(p_schro_params->decoder); |
| 353 | 353 |
p_schro_params->eos_pulled = 0; |
| 354 | 354 |
p_schro_params->eos_signalled = 0; |
| 355 | 355 |
} |
| 356 | 356 |
|
| 357 | 357 |
AVCodec libschroedinger_decoder = {
|
| 358 |
- "libschroedinger", |
|
| 358 |
+ "libschroedinger", |
|
| 359 | 359 |
CODEC_TYPE_VIDEO, |
| 360 | 360 |
CODEC_ID_DIRAC, |
| 361 | 361 |
sizeof(FfmpegSchroDecoderParams), |
| ... | ... |
@@ -40,8 +40,7 @@ |
| 40 | 40 |
|
| 41 | 41 |
|
| 42 | 42 |
/** libschroedinger encoder private data */ |
| 43 |
-typedef struct FfmpegSchroEncoderParams |
|
| 44 |
-{
|
|
| 43 |
+typedef struct FfmpegSchroEncoderParams {
|
|
| 45 | 44 |
/** Schroedinger video format */ |
| 46 | 45 |
SchroVideoFormat *format; |
| 47 | 46 |
|
| ... | ... |
@@ -86,16 +85,16 @@ static int SetSchroChromaFormat(AVCodecContext *avccontext) |
| 86 | 86 |
|
| 87 | 87 |
for (idx = 0; idx < num_formats; ++idx) {
|
| 88 | 88 |
if (ffmpeg_schro_pixel_format_map[idx].ff_pix_fmt == |
| 89 |
- avccontext->pix_fmt) {
|
|
| 89 |
+ avccontext->pix_fmt) {
|
|
| 90 | 90 |
p_schro_params->format->chroma_format = |
| 91 | 91 |
ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt; |
| 92 | 92 |
return 0; |
| 93 | 93 |
} |
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 |
- av_log (avccontext, AV_LOG_ERROR, |
|
| 97 |
- "This codec currently only supports planar YUV 4:2:0, 4:2:2" |
|
| 98 |
- " and 4:4:4 formats.\n"); |
|
| 96 |
+ av_log(avccontext, AV_LOG_ERROR, |
|
| 97 |
+ "This codec currently only supports planar YUV 4:2:0, 4:2:2" |
|
| 98 |
+ " and 4:4:4 formats.\n"); |
|
| 99 | 99 |
|
| 100 | 100 |
return -1; |
| 101 | 101 |
} |
| ... | ... |
@@ -121,8 +120,8 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) |
| 121 | 121 |
preset = ff_get_schro_video_format_preset(avccontext); |
| 122 | 122 |
p_schro_params->format = |
| 123 | 123 |
schro_encoder_get_video_format(p_schro_params->encoder); |
| 124 |
- schro_video_format_set_std_video_format (p_schro_params->format, preset); |
|
| 125 |
- p_schro_params->format->width = avccontext->width; |
|
| 124 |
+ schro_video_format_set_std_video_format(p_schro_params->format, preset); |
|
| 125 |
+ p_schro_params->format->width = avccontext->width; |
|
| 126 | 126 |
p_schro_params->format->height = avccontext->height; |
| 127 | 127 |
|
| 128 | 128 |
if (SetSchroChromaFormat(avccontext) == -1) |
| ... | ... |
@@ -130,9 +129,9 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) |
| 130 | 130 |
|
| 131 | 131 |
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format, |
| 132 | 132 |
&p_schro_params->frame_format) == -1) {
|
| 133 |
- av_log (avccontext, AV_LOG_ERROR, |
|
| 134 |
- "This codec currently supports only planar YUV 4:2:0, 4:2:2" |
|
| 135 |
- " and 4:4:4 formats.\n"); |
|
| 133 |
+ av_log(avccontext, AV_LOG_ERROR, |
|
| 134 |
+ "This codec currently supports only planar YUV 4:2:0, 4:2:2" |
|
| 135 |
+ " and 4:4:4 formats.\n"); |
|
| 136 | 136 |
return -1; |
| 137 | 137 |
} |
| 138 | 138 |
|
| ... | ... |
@@ -146,18 +145,17 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) |
| 146 | 146 |
avccontext->coded_frame = &p_schro_params->picture; |
| 147 | 147 |
|
| 148 | 148 |
if (!avccontext->gop_size) {
|
| 149 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 150 |
- "gop_structure", |
|
| 151 |
- SCHRO_ENCODER_GOP_INTRA_ONLY); |
|
| 149 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 150 |
+ "gop_structure", |
|
| 151 |
+ SCHRO_ENCODER_GOP_INTRA_ONLY); |
|
| 152 | 152 |
|
| 153 | 153 |
if (avccontext->coder_type == FF_CODER_TYPE_VLC) |
| 154 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 155 |
- "enable_noarith", 1); |
|
| 156 |
- } |
|
| 157 |
- else {
|
|
| 158 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 159 |
- "gop_structure", |
|
| 160 |
- SCHRO_ENCODER_GOP_BIREF); |
|
| 154 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 155 |
+ "enable_noarith", 1); |
|
| 156 |
+ } else {
|
|
| 157 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 158 |
+ "gop_structure", |
|
| 159 |
+ SCHRO_ENCODER_GOP_BIREF); |
|
| 161 | 160 |
avccontext->has_b_frames = 1; |
| 162 | 161 |
} |
| 163 | 162 |
|
| ... | ... |
@@ -165,39 +163,38 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) |
| 165 | 165 |
if (avccontext->flags & CODEC_FLAG_QSCALE) {
|
| 166 | 166 |
if (!avccontext->global_quality) {
|
| 167 | 167 |
/* lossless coding */ |
| 168 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 169 |
- "rate_control", |
|
| 170 |
- SCHRO_ENCODER_RATE_CONTROL_LOSSLESS); |
|
| 168 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 169 |
+ "rate_control", |
|
| 170 |
+ SCHRO_ENCODER_RATE_CONTROL_LOSSLESS); |
|
| 171 | 171 |
} else {
|
| 172 | 172 |
int noise_threshold; |
| 173 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 174 |
- "rate_control", |
|
| 175 |
- SCHRO_ENCODER_RATE_CONTROL_CONSTANT_NOISE_THRESHOLD); |
|
| 173 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 174 |
+ "rate_control", |
|
| 175 |
+ SCHRO_ENCODER_RATE_CONTROL_CONSTANT_NOISE_THRESHOLD); |
|
| 176 | 176 |
|
| 177 |
- noise_threshold = avccontext->global_quality/FF_QP2LAMBDA; |
|
| 177 |
+ noise_threshold = avccontext->global_quality / FF_QP2LAMBDA; |
|
| 178 | 178 |
if (noise_threshold > 100) |
| 179 | 179 |
noise_threshold = 100; |
| 180 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 181 |
- "noise_threshold", |
|
| 182 |
- noise_threshold); |
|
| 180 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 181 |
+ "noise_threshold", |
|
| 182 |
+ noise_threshold); |
|
| 183 | 183 |
} |
| 184 |
- } |
|
| 185 |
- else {
|
|
| 186 |
- schro_encoder_setting_set_double ( p_schro_params->encoder, |
|
| 187 |
- "rate_control", |
|
| 188 |
- SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE); |
|
| 184 |
+ } else {
|
|
| 185 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 186 |
+ "rate_control", |
|
| 187 |
+ SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE); |
|
| 189 | 188 |
|
| 190 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 191 |
- "bitrate", |
|
| 192 |
- avccontext->bit_rate); |
|
| 189 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 190 |
+ "bitrate", |
|
| 191 |
+ avccontext->bit_rate); |
|
| 193 | 192 |
|
| 194 | 193 |
} |
| 195 | 194 |
|
| 196 | 195 |
if (avccontext->flags & CODEC_FLAG_INTERLACED_ME) |
| 197 | 196 |
/* All material can be coded as interlaced or progressive |
| 198 | 197 |
irrespective of the type of source material. */ |
| 199 |
- schro_encoder_setting_set_double (p_schro_params->encoder, |
|
| 200 |
- "interlaced_coding", 1); |
|
| 198 |
+ schro_encoder_setting_set_double(p_schro_params->encoder, |
|
| 199 |
+ "interlaced_coding", 1); |
|
| 201 | 200 |
|
| 202 | 201 |
/* FIXME: Signal range hardcoded to 8-bit data until both libschroedinger |
| 203 | 202 |
* and libdirac support other bit-depth data. */ |
| ... | ... |
@@ -209,32 +206,32 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) |
| 209 | 209 |
p_schro_params->format); |
| 210 | 210 |
|
| 211 | 211 |
/* Set the debug level. */ |
| 212 |
- schro_debug_set_level (avccontext->debug); |
|
| 212 |
+ schro_debug_set_level(avccontext->debug); |
|
| 213 | 213 |
|
| 214 |
- schro_encoder_start (p_schro_params->encoder); |
|
| 214 |
+ schro_encoder_start(p_schro_params->encoder); |
|
| 215 | 215 |
|
| 216 | 216 |
/* Initialize the encoded frame queue. */ |
| 217 |
- ff_dirac_schro_queue_init (&p_schro_params->enc_frame_queue); |
|
| 218 |
- return 0 ; |
|
| 217 |
+ ff_dirac_schro_queue_init(&p_schro_params->enc_frame_queue); |
|
| 218 |
+ return 0; |
|
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 |
-static SchroFrame *libschroedinger_frame_from_data (AVCodecContext *avccontext, |
|
| 222 |
- void *in_data) |
|
| 221 |
+static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avccontext, |
|
| 222 |
+ void *in_data) |
|
| 223 | 223 |
{
|
| 224 | 224 |
FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; |
| 225 | 225 |
SchroFrame *in_frame; |
| 226 | 226 |
/* Input line size may differ from what the codec supports. Especially |
| 227 | 227 |
* when transcoding from one format to another. So use avpicture_layout |
| 228 | 228 |
* to copy the frame. */ |
| 229 |
- in_frame = schro_frame_new_and_alloc (NULL, |
|
| 230 |
- p_schro_params->frame_format, |
|
| 231 |
- p_schro_params->format->width, |
|
| 232 |
- p_schro_params->format->height); |
|
| 229 |
+ in_frame = schro_frame_new_and_alloc(NULL, |
|
| 230 |
+ p_schro_params->frame_format, |
|
| 231 |
+ p_schro_params->format->width, |
|
| 232 |
+ p_schro_params->format->height); |
|
| 233 | 233 |
|
| 234 |
- avpicture_layout ((AVPicture *)in_data, avccontext->pix_fmt, |
|
| 235 |
- avccontext->width, avccontext->height, |
|
| 236 |
- in_frame->components[0].data, |
|
| 237 |
- p_schro_params->frame_size); |
|
| 234 |
+ avpicture_layout((AVPicture *)in_data, avccontext->pix_fmt, |
|
| 235 |
+ avccontext->width, avccontext->height, |
|
| 236 |
+ in_frame->components[0].data, |
|
| 237 |
+ p_schro_params->frame_size); |
|
| 238 | 238 |
|
| 239 | 239 |
return in_frame; |
| 240 | 240 |
} |
| ... | ... |
@@ -243,7 +240,7 @@ static void SchroedingerFreeFrame(void *data) |
| 243 | 243 |
{
|
| 244 | 244 |
FfmpegDiracSchroEncodedFrame *enc_frame = data; |
| 245 | 245 |
|
| 246 |
- av_freep (&(enc_frame->p_encbuf)); |
|
| 246 |
+ av_freep(&(enc_frame->p_encbuf)); |
|
| 247 | 247 |
av_free(enc_frame); |
| 248 | 248 |
} |
| 249 | 249 |
|
| ... | ... |
@@ -269,8 +266,8 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 269 | 269 |
} |
| 270 | 270 |
} else {
|
| 271 | 271 |
/* Allocate frame data to schro input buffer. */ |
| 272 |
- SchroFrame *in_frame = libschroedinger_frame_from_data (avccontext, |
|
| 273 |
- data); |
|
| 272 |
+ SchroFrame *in_frame = libschroedinger_frame_from_data(avccontext, |
|
| 273 |
+ data); |
|
| 274 | 274 |
/* Load next frame. */ |
| 275 | 275 |
schro_encoder_push_frame(encoder, in_frame); |
| 276 | 276 |
} |
| ... | ... |
@@ -280,28 +277,24 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 280 | 280 |
|
| 281 | 281 |
/* Now check to see if we have any output from the encoder. */ |
| 282 | 282 |
while (go) {
|
| 283 |
- SchroStateEnum state; |
|
| 283 |
+ SchroStateEnum state; |
|
| 284 | 284 |
state = schro_encoder_wait(encoder); |
| 285 |
- switch (state) |
|
| 286 |
- {
|
|
| 285 |
+ switch (state) {
|
|
| 287 | 286 |
case SCHRO_STATE_HAVE_BUFFER: |
| 288 | 287 |
case SCHRO_STATE_END_OF_STREAM: |
| 289 |
- enc_buf = schro_encoder_pull (encoder, |
|
| 290 |
- &presentation_frame); |
|
| 291 |
- assert (enc_buf->length > 0); |
|
| 292 |
- assert (enc_buf->length <= buf_size); |
|
| 288 |
+ enc_buf = schro_encoder_pull(encoder, &presentation_frame); |
|
| 289 |
+ assert(enc_buf->length > 0); |
|
| 290 |
+ assert(enc_buf->length <= buf_size); |
|
| 293 | 291 |
parse_code = enc_buf->data[4]; |
| 294 | 292 |
|
| 295 | 293 |
/* All non-frame data is prepended to actual frame data to |
| 296 | 294 |
* be able to set the pts correctly. So we don't write data |
| 297 | 295 |
* to the frame output queue until we actually have a frame |
| 298 | 296 |
*/ |
| 299 |
- p_schro_params->enc_buf = av_realloc ( |
|
| 300 |
- p_schro_params->enc_buf, |
|
| 301 |
- p_schro_params->enc_buf_size + enc_buf->length |
|
| 302 |
- ); |
|
| 297 |
+ p_schro_params->enc_buf = av_realloc(p_schro_params->enc_buf, |
|
| 298 |
+ p_schro_params->enc_buf_size + enc_buf->length); |
|
| 303 | 299 |
|
| 304 |
- memcpy(p_schro_params->enc_buf+p_schro_params->enc_buf_size, |
|
| 300 |
+ memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size, |
|
| 305 | 301 |
enc_buf->data, enc_buf->length); |
| 306 | 302 |
p_schro_params->enc_buf_size += enc_buf->length; |
| 307 | 303 |
|
| ... | ... |
@@ -312,7 +305,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 312 | 312 |
} |
| 313 | 313 |
|
| 314 | 314 |
if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {
|
| 315 |
- schro_buffer_unref (enc_buf); |
|
| 315 |
+ schro_buffer_unref(enc_buf); |
|
| 316 | 316 |
break; |
| 317 | 317 |
} |
| 318 | 318 |
|
| ... | ... |
@@ -332,12 +325,12 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 332 | 332 |
(enc_buf->data[15] << 8) + |
| 333 | 333 |
enc_buf->data[16]; |
| 334 | 334 |
|
| 335 |
- ff_dirac_schro_queue_push_back (&p_schro_params->enc_frame_queue, |
|
| 336 |
- p_frame_output); |
|
| 335 |
+ ff_dirac_schro_queue_push_back(&p_schro_params->enc_frame_queue, |
|
| 336 |
+ p_frame_output); |
|
| 337 | 337 |
p_schro_params->enc_buf_size = 0; |
| 338 | 338 |
p_schro_params->enc_buf = NULL; |
| 339 | 339 |
|
| 340 |
- schro_buffer_unref (enc_buf); |
|
| 340 |
+ schro_buffer_unref(enc_buf); |
|
| 341 | 341 |
|
| 342 | 342 |
break; |
| 343 | 343 |
|
| ... | ... |
@@ -360,8 +353,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 360 | 360 |
p_schro_params->eos_pulled) |
| 361 | 361 |
last_frame_in_sequence = 1; |
| 362 | 362 |
|
| 363 |
- p_frame_output = |
|
| 364 |
- ff_dirac_schro_queue_pop (&p_schro_params->enc_frame_queue); |
|
| 363 |
+ p_frame_output = ff_dirac_schro_queue_pop(&p_schro_params->enc_frame_queue); |
|
| 365 | 364 |
|
| 366 | 365 |
if (!p_frame_output) |
| 367 | 366 |
return 0; |
| ... | ... |
@@ -376,17 +368,16 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 376 | 376 |
|
| 377 | 377 |
/* Append the end of sequence information to the last frame in the |
| 378 | 378 |
* sequence. */ |
| 379 |
- if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) |
|
| 380 |
- {
|
|
| 381 |
- memcpy (frame + enc_size, p_schro_params->enc_buf, |
|
| 382 |
- p_schro_params->enc_buf_size); |
|
| 379 |
+ if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) {
|
|
| 380 |
+ memcpy(frame + enc_size, p_schro_params->enc_buf, |
|
| 381 |
+ p_schro_params->enc_buf_size); |
|
| 383 | 382 |
enc_size += p_schro_params->enc_buf_size; |
| 384 |
- av_freep (&p_schro_params->enc_buf); |
|
| 383 |
+ av_freep(&p_schro_params->enc_buf); |
|
| 385 | 384 |
p_schro_params->enc_buf_size = 0; |
| 386 | 385 |
} |
| 387 | 386 |
|
| 388 | 387 |
/* free frame */ |
| 389 |
- SchroedingerFreeFrame (p_frame_output); |
|
| 388 |
+ SchroedingerFreeFrame(p_frame_output); |
|
| 390 | 389 |
|
| 391 | 390 |
return enc_size; |
| 392 | 391 |
} |
| ... | ... |
@@ -397,12 +388,12 @@ static int libschroedinger_encode_close(AVCodecContext *avccontext) |
| 397 | 397 |
|
| 398 | 398 |
FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; |
| 399 | 399 |
|
| 400 |
- /* Close the encoder. */ |
|
| 400 |
+ /* Close the encoder. */ |
|
| 401 | 401 |
schro_encoder_free(p_schro_params->encoder); |
| 402 | 402 |
|
| 403 | 403 |
/* Free data in the output frame queue. */ |
| 404 |
- ff_dirac_schro_queue_free (&p_schro_params->enc_frame_queue, |
|
| 405 |
- SchroedingerFreeFrame); |
|
| 404 |
+ ff_dirac_schro_queue_free(&p_schro_params->enc_frame_queue, |
|
| 405 |
+ SchroedingerFreeFrame); |
|
| 406 | 406 |
|
| 407 | 407 |
|
| 408 | 408 |
/* Free the encoder buffer. */ |
| ... | ... |
@@ -412,7 +403,7 @@ static int libschroedinger_encode_close(AVCodecContext *avccontext) |
| 412 | 412 |
/* Free the video format structure. */ |
| 413 | 413 |
av_freep(&p_schro_params->format); |
| 414 | 414 |
|
| 415 |
- return 0 ; |
|
| 415 |
+ return 0; |
|
| 416 | 416 |
} |
| 417 | 417 |
|
| 418 | 418 |
|
| ... | ... |
@@ -424,7 +415,7 @@ AVCodec libschroedinger_encoder = {
|
| 424 | 424 |
libschroedinger_encode_init, |
| 425 | 425 |
libschroedinger_encode_frame, |
| 426 | 426 |
libschroedinger_encode_close, |
| 427 |
- .capabilities= CODEC_CAP_DELAY, |
|
| 428 |
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_NONE},
|
|
| 429 |
- .long_name= NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"),
|
|
| 427 |
+ .capabilities = CODEC_CAP_DELAY, |
|
| 428 |
+ .pix_fmts = (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_NONE},
|
|
| 429 |
+ .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"),
|
|
| 430 | 430 |
}; |