]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/roqvideoenc.c
fix compilation with --disable-everything --enable-decoder=mpeg2video
[ffmpeg] / libavcodec / roqvideoenc.c
index 6e04f5c5704b550cc559c02a436faaa7c9e93555..8dc77bd414cdd8a71db6ff69f4689f71ded820e8 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 /**
- * @file roqvideoenc.c
+ * @file libavcodec/roqvideoenc.c
  * id RoQ encoder by Vitor. Based on the Switchblade3 library and the
  * Switchblade3 FFmpeg glue by Eric Lasota.
  */
@@ -55,7 +55,6 @@
  */
 
 #include <string.h>
-#include <unistd.h>
 
 #include "roqvideo.h"
 #include "bytestream.h"
@@ -220,7 +219,7 @@ typedef struct
 /**
  * Temporary vars
  */
-typedef struct
+typedef struct RoqTempData
 {
     CelEvaluation *cel_evals;
 
@@ -796,7 +795,7 @@ static void generate_codebook(RoqContext *enc, RoqTempdata *tempdata,
 {
     int i, j, k;
     int c_size = size*size/4;
-    int *buf = points;
+    int *buf;
     int *codebook = av_malloc(6*c_size*cbsize*sizeof(int));
     int *closest_cb;
 
@@ -881,14 +880,14 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
 
 static void roq_encode_video(RoqContext *enc)
 {
-    RoqTempdata tempData;
+    RoqTempdata *tempData = enc->tmpData;
     int i;
 
-    memset(&tempData, 0, sizeof(tempData));
+    memset(tempData, 0, sizeof(*tempData));
 
-    create_cel_evals(enc, &tempData);
+    create_cel_evals(enc, tempData);
 
-    generate_new_codebooks(enc, &tempData);
+    generate_new_codebooks(enc, tempData);
 
     if (enc->framesSinceKeyframe >= 1) {
         motion_search(enc, 8);
@@ -897,19 +896,19 @@ static void roq_encode_video(RoqContext *enc)
 
  retry_encode:
     for (i=0; i<enc->width*enc->height/64; i++)
-        gather_data_for_cel(tempData.cel_evals + i, enc, &tempData);
+        gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
 
     /* Quake 3 can't handle chunks bigger than 65536 bytes */
-    if (tempData.mainChunkSize/8 > 65536) {
+    if (tempData->mainChunkSize/8 > 65536) {
         enc->lambda *= .8;
         goto retry_encode;
     }
 
-    remap_codebooks(enc, &tempData);
+    remap_codebooks(enc, tempData);
 
-    write_codebooks(enc, &tempData);
+    write_codebooks(enc, tempData);
 
-    reconstruct_and_encode_image(enc, &tempData, enc->width, enc->height,
+    reconstruct_and_encode_image(enc, tempData, enc->width, enc->height,
                                  enc->width*enc->height/64);
 
     enc->avctx->coded_frame = enc->current_frame;
@@ -919,8 +918,8 @@ static void roq_encode_video(RoqContext *enc)
     FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4);
     FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8);
 
-    av_free(tempData.cel_evals);
-    av_free(tempData.closest_cb2);
+    av_free(tempData->cel_evals);
+    av_free(tempData->closest_cb2);
 
     enc->framesSinceKeyframe++;
 }
@@ -929,7 +928,7 @@ static int roq_encode_init(AVCodecContext *avctx)
 {
     RoqContext *enc = avctx->priv_data;
 
-    av_random_init(&enc->randctx, 1);
+    av_lfg_init(&enc->randctx, 1);
 
     enc->framesSinceKeyframe = 0;
     if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
@@ -940,12 +939,6 @@ static int roq_encode_init(AVCodecContext *avctx)
     if (((avctx->width)&(avctx->width-1))||((avctx->height)&(avctx->height-1)))
         av_log(avctx, AV_LOG_ERROR, "Warning: dimensions not power of two\n");
 
-    if (avcodec_check_dimensions(avctx, avctx->width, avctx->height)) {
-        av_log(avctx, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n",
-               avctx->width, avctx->height);
-        return -1;
-    }
-
     enc->width = avctx->width;
     enc->height = avctx->height;
 
@@ -955,6 +948,8 @@ static int roq_encode_init(AVCodecContext *avctx)
     enc->last_frame    = &enc->frames[0];
     enc->current_frame = &enc->frames[1];
 
+    enc->tmpData      = av_malloc(sizeof(RoqTempdata));
+
     enc->this_motion4 =
         av_mallocz((enc->width*enc->height/16)*sizeof(motion_vect));
 
@@ -1050,6 +1045,7 @@ static int roq_encode_end(AVCodecContext *avctx)
     avctx->release_buffer(avctx, enc->last_frame);
     avctx->release_buffer(avctx, enc->current_frame);
 
+    av_free(enc->tmpData);
     av_free(enc->this_motion4);
     av_free(enc->last_motion4);
     av_free(enc->this_motion8);
@@ -1067,7 +1063,7 @@ AVCodec roq_encoder =
     roq_encode_init,
     roq_encode_frame,
     roq_encode_end,
-    .supported_framerates = (AVRational[]){{30,1}, {0,0}},
-    .pix_fmts = (enum PixelFormat[]){PIX_FMT_YUV444P, PIX_FMT_NONE},
+    .supported_framerates = (const AVRational[]){{30,1}, {0,0}},
+    .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV444P, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("id RoQ video"),
 };