~ppsspp/ppsspp/ffmpeg

« back to all changes in this revision

Viewing changes to libavcodec/qtrleenc.c

  • Committer: Henrik Rydgård
  • Date: 2014-01-03 10:44:32 UTC
  • Revision ID: git-v1:87c6c126784b1718bfa448ecf2e6a9fef781eb4e
Update our ffmpeg snapshot to a clone of the official repository.

This is because Maxim's at3plus support has been officially merged!

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
typedef struct QtrleEncContext {
38
38
    AVCodecContext *avctx;
39
 
    AVFrame frame;
40
39
    int pixel_size;
41
40
    AVPicture previous_frame;
42
41
    unsigned int max_buf_size;
61
60
    uint8_t* skip_table;
62
61
} QtrleEncContext;
63
62
 
 
63
static av_cold int qtrle_encode_end(AVCodecContext *avctx)
 
64
{
 
65
    QtrleEncContext *s = avctx->priv_data;
 
66
 
 
67
    av_frame_free(&avctx->coded_frame);
 
68
 
 
69
    avpicture_free(&s->previous_frame);
 
70
    av_free(s->rlecode_table);
 
71
    av_free(s->length_table);
 
72
    av_free(s->skip_table);
 
73
    return 0;
 
74
}
 
75
 
64
76
static av_cold int qtrle_encode_init(AVCodecContext *avctx)
65
77
{
66
78
    QtrleEncContext *s = avctx->priv_data;
108
120
                      + 15                                            /* header + footer */
109
121
                      + s->avctx->height*2                            /* skip code+rle end */
110
122
                      + s->logical_width/MAX_RLE_BULK + 1             /* rle codes */;
111
 
    avctx->coded_frame = &s->frame;
 
123
 
 
124
    avctx->coded_frame = av_frame_alloc();
 
125
    if (!avctx->coded_frame) {
 
126
        qtrle_encode_end(avctx);
 
127
        return AVERROR(ENOMEM);
 
128
    }
 
129
 
112
130
    return 0;
113
131
}
114
132
 
197
215
            }
198
216
        }
199
217
 
200
 
        if (!s->frame.key_frame && !memcmp(this_line, prev_line, s->pixel_size))
 
218
        if (!s->avctx->coded_frame->key_frame && !memcmp(this_line, prev_line, s->pixel_size))
201
219
            skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP);
202
220
        else
203
221
            skipcount = 0;
308
326
    int end_line = s->avctx->height;
309
327
    uint8_t *orig_buf = buf;
310
328
 
311
 
    if (!s->frame.key_frame) {
 
329
    if (!s->avctx->coded_frame->key_frame) {
312
330
        unsigned line_size = s->logical_width * s->pixel_size;
313
331
        for (start_line = 0; start_line < s->avctx->height; start_line++)
314
332
            if (memcmp(p->data[0] + start_line*p->linesize[0],
346
364
                              const AVFrame *pict, int *got_packet)
347
365
{
348
366
    QtrleEncContext * const s = avctx->priv_data;
349
 
    AVFrame * const p = &s->frame;
 
367
    AVFrame * const p = avctx->coded_frame;
350
368
    int ret;
351
369
 
352
 
    *p = *pict;
353
 
 
354
370
    if ((ret = ff_alloc_packet2(avctx, pkt, s->max_buf_size)) < 0)
355
371
        return ret;
356
372
 
367
383
    pkt->size = encode_frame(s, pict, pkt->data);
368
384
 
369
385
    /* save the current frame */
370
 
    av_picture_copy(&s->previous_frame, (AVPicture *)p, avctx->pix_fmt, avctx->width, avctx->height);
 
386
    av_picture_copy(&s->previous_frame, (const AVPicture *)pict,
 
387
                    avctx->pix_fmt, avctx->width, avctx->height);
371
388
 
372
389
    if (p->key_frame)
373
390
        pkt->flags |= AV_PKT_FLAG_KEY;
376
393
    return 0;
377
394
}
378
395
 
379
 
static av_cold int qtrle_encode_end(AVCodecContext *avctx)
380
 
{
381
 
    QtrleEncContext *s = avctx->priv_data;
382
 
 
383
 
    avpicture_free(&s->previous_frame);
384
 
    av_free(s->rlecode_table);
385
 
    av_free(s->length_table);
386
 
    av_free(s->skip_table);
387
 
    return 0;
388
 
}
389
 
 
390
396
AVCodec ff_qtrle_encoder = {
391
397
    .name           = "qtrle",
392
398
    .long_name      = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"),