~ubuntu-branches/ubuntu/utopic/ffmpeg-debian/utopic

« back to all changes in this revision

Viewing changes to libavcodec/roqvideoenc.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
#include "roqvideo.h"
61
61
#include "bytestream.h"
62
62
#include "elbg.h"
 
63
#include "mathops.h"
63
64
 
64
65
#define CHROMA_BIAS 1
65
66
 
190
191
    int subCels[4];
191
192
    motion_vect motion;
192
193
    int cbEntry;
193
 
} subcel_evaluation_t;
 
194
} SubcelEvaluation;
194
195
 
195
196
typedef struct
196
197
{
197
198
    int eval_dist[4];
198
199
    int best_coding;
199
200
 
200
 
    subcel_evaluation_t subCels[4];
 
201
    SubcelEvaluation subCels[4];
201
202
 
202
203
    motion_vect motion;
203
204
    int cbEntry;
204
205
 
205
206
    int sourceX, sourceY;
206
 
} cel_evaluation_t;
 
207
} CelEvaluation;
207
208
 
208
209
typedef struct
209
210
{
214
215
    uint8_t unpacked_cb2[MAX_CBS_2x2*2*2*3];
215
216
    uint8_t unpacked_cb4[MAX_CBS_4x4*4*4*3];
216
217
    uint8_t unpacked_cb4_enlarged[MAX_CBS_4x4*8*8*3];
217
 
} roq_codebooks_t;
 
218
} RoqCodebooks;
218
219
 
219
220
/**
220
221
 * Temporary vars
221
222
 */
222
223
typedef struct
223
224
{
224
 
    cel_evaluation_t *cel_evals;
 
225
    CelEvaluation *cel_evals;
225
226
 
226
227
    int f2i4[MAX_CBS_4x4];
227
228
    int i2f4[MAX_CBS_4x4];
233
234
    int numCB4;
234
235
    int numCB2;
235
236
 
236
 
    roq_codebooks_t codebooks;
 
237
    RoqCodebooks codebooks;
237
238
 
238
239
    int *closest_cb2;
239
240
    int used_option[4];
240
 
} roq_tempdata_t;
 
241
} RoqTempdata;
241
242
 
242
243
/**
243
244
 * Initializes cel evaluators and sets their source coordinates
244
245
 */
245
 
static void create_cel_evals(RoqContext *enc, roq_tempdata_t *tempData)
 
246
static void create_cel_evals(RoqContext *enc, RoqTempdata *tempData)
246
247
{
247
248
    int n=0, x, y, i;
248
249
 
249
 
    tempData->cel_evals = av_malloc(enc->width*enc->height/64 * sizeof(cel_evaluation_t));
 
250
    tempData->cel_evals = av_malloc(enc->width*enc->height/64 * sizeof(CelEvaluation));
250
251
 
251
252
    /* Map to the ROQ quadtree order */
252
253
    for (y=0; y<enc->height; y+=16)
395
396
/**
396
397
 * Gets distortion for all options available to a subcel
397
398
 */
398
 
static void gather_data_for_subcel(subcel_evaluation_t *subcel, int x,
399
 
                                   int y, RoqContext *enc, roq_tempdata_t *tempData)
 
399
static void gather_data_for_subcel(SubcelEvaluation *subcel, int x,
 
400
                                   int y, RoqContext *enc, RoqTempdata *tempData)
400
401
{
401
402
    uint8_t mb4[4*4*3];
402
403
    uint8_t mb2[2*2*3];
459
460
/**
460
461
 * Gets distortion for all options available to a cel
461
462
 */
462
 
static void gather_data_for_cel(cel_evaluation_t *cel, RoqContext *enc,
463
 
                                roq_tempdata_t *tempData)
 
463
static void gather_data_for_cel(CelEvaluation *cel, RoqContext *enc,
 
464
                                RoqTempdata *tempData)
464
465
{
465
466
    uint8_t mb8[8*8*3];
466
467
    int index = cel->sourceY*enc->width/64 + cel->sourceX/8;
533
534
        }
534
535
}
535
536
 
536
 
static void remap_codebooks(RoqContext *enc, roq_tempdata_t *tempData)
 
537
static void remap_codebooks(RoqContext *enc, RoqTempdata *tempData)
537
538
{
538
539
    int i, j, idx=0;
539
540
 
565
566
/**
566
567
 * Write codebook chunk
567
568
 */
568
 
static void write_codebooks(RoqContext *enc, roq_tempdata_t *tempData)
 
569
static void write_codebooks(RoqContext *enc, RoqTempdata *tempData)
569
570
{
570
571
    int i, j;
571
572
    uint8_t **outp= &enc->out_buf;
620
621
    }
621
622
}
622
623
 
623
 
static void reconstruct_and_encode_image(RoqContext *enc, roq_tempdata_t *tempData, int w, int h, int numBlocks)
 
624
static void reconstruct_and_encode_image(RoqContext *enc, RoqTempdata *tempData, int w, int h, int numBlocks)
624
625
{
625
626
    int i, j, k;
626
627
    int x, y;
628
629
    int dist=0;
629
630
 
630
631
    roq_qcell *qcell;
631
 
    cel_evaluation_t *eval;
 
632
    CelEvaluation *eval;
632
633
 
633
634
    CodingSpool spool;
634
635
 
789
790
        }
790
791
}
791
792
 
792
 
static void generate_codebook(RoqContext *enc, roq_tempdata_t *tempdata,
 
793
static void generate_codebook(RoqContext *enc, RoqTempdata *tempdata,
793
794
                              int *points, int inputCount, roq_cell *results,
794
795
                              int size, int cbsize)
795
796
{
824
825
    av_free(codebook);
825
826
}
826
827
 
827
 
static void generate_new_codebooks(RoqContext *enc, roq_tempdata_t *tempData)
 
828
static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
828
829
{
829
830
    int i,j;
830
 
    roq_codebooks_t *codebooks = &tempData->codebooks;
 
831
    RoqCodebooks *codebooks = &tempData->codebooks;
831
832
    int max = enc->width*enc->height/16;
832
833
    uint8_t mb2[3*4];
833
834
    roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
880
881
 
881
882
static void roq_encode_video(RoqContext *enc)
882
883
{
883
 
    roq_tempdata_t tempData;
 
884
    RoqTempdata tempData;
884
885
    int i;
885
886
 
886
887
    memset(&tempData, 0, sizeof(tempData));