~siretart/libav/trusty-security

« back to all changes in this revision

Viewing changes to libavcodec/libschroedinger.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2013-10-22 23:24:08 UTC
  • mfrom: (1.3.36 sid)
  • Revision ID: package-import@ubuntu.com-20131022232408-b8tvvn4pyzri9mi3
Tags: 6:9.10-1ubuntu1
* Build all -extra flavors from this source package, as libav got demoted
  from main to universe, cf LP: #1243235
* Simplify debian/rules to follow exactly the code that debian executes
* New upstream (LP: #1180288) fixes lots of security issues (LP: #1242802)
* Merge from unstable, remaining changes:
  - build-depend on libtiff5-dev rather than libtiff4-dev,
    avoids FTBFS caused by imlib
  - follow the regular debian codepaths

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
* function definitions common to libschroedinger decoder and encoder
24
24
*/
25
25
 
26
 
#include "libdirac_libschro.h"
27
26
#include "libschroedinger.h"
 
27
#include "libavutil/mem.h"
 
28
 
 
29
static const SchroVideoFormatInfo ff_schro_video_format_info[] = {
 
30
    { 640,  480,  24000, 1001},
 
31
    { 176,  120,  15000, 1001},
 
32
    { 176,  144,  25,    2   },
 
33
    { 352,  240,  15000, 1001},
 
34
    { 352,  288,  25,    2   },
 
35
    { 704,  480,  15000, 1001},
 
36
    { 704,  576,  25,    2   },
 
37
    { 720,  480,  30000, 1001},
 
38
    { 720,  576,  25,    1   },
 
39
    { 1280, 720,  60000, 1001},
 
40
    { 1280, 720,  50,    1   },
 
41
    { 1920, 1080, 30000, 1001},
 
42
    { 1920, 1080, 25,    1   },
 
43
    { 1920, 1080, 60000, 1001},
 
44
    { 1920, 1080, 50,    1   },
 
45
    { 2048, 1080, 24,    1   },
 
46
    { 4096, 2160, 24,    1   },
 
47
};
 
48
 
 
49
static unsigned int get_video_format_idx(AVCodecContext *avccontext)
 
50
{
 
51
    unsigned int ret_idx = 0;
 
52
    unsigned int idx;
 
53
    unsigned int num_formats = sizeof(ff_schro_video_format_info) /
 
54
                               sizeof(ff_schro_video_format_info[0]);
 
55
 
 
56
    for (idx = 1; idx < num_formats; ++idx) {
 
57
        const SchroVideoFormatInfo *vf = &ff_schro_video_format_info[idx];
 
58
        if (avccontext->width  == vf->width &&
 
59
            avccontext->height == vf->height) {
 
60
            ret_idx = idx;
 
61
            if (avccontext->time_base.den == vf->frame_rate_num &&
 
62
                avccontext->time_base.num == vf->frame_rate_denom)
 
63
                return idx;
 
64
        }
 
65
    }
 
66
    return ret_idx;
 
67
}
 
68
 
 
69
void ff_schro_queue_init(FFSchroQueue *queue)
 
70
{
 
71
    queue->p_head = queue->p_tail = NULL;
 
72
    queue->size = 0;
 
73
}
 
74
 
 
75
void ff_schro_queue_free(FFSchroQueue *queue, void (*free_func)(void *))
 
76
{
 
77
    while (queue->p_head)
 
78
        free_func(ff_schro_queue_pop(queue));
 
79
}
 
80
 
 
81
int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data)
 
82
{
 
83
    FFSchroQueueElement *p_new = av_mallocz(sizeof(FFSchroQueueElement));
 
84
 
 
85
    if (!p_new)
 
86
        return -1;
 
87
 
 
88
    p_new->data = p_data;
 
89
 
 
90
    if (!queue->p_head)
 
91
        queue->p_head = p_new;
 
92
    else
 
93
        queue->p_tail->next = p_new;
 
94
    queue->p_tail = p_new;
 
95
 
 
96
    ++queue->size;
 
97
    return 0;
 
98
}
 
99
 
 
100
void *ff_schro_queue_pop(FFSchroQueue *queue)
 
101
{
 
102
    FFSchroQueueElement *top = queue->p_head;
 
103
 
 
104
    if (top) {
 
105
        void *data = top->data;
 
106
        queue->p_head = queue->p_head->next;
 
107
        --queue->size;
 
108
        av_freep(&top);
 
109
        return data;
 
110
    }
 
111
 
 
112
    return NULL;
 
113
}
28
114
 
29
115
/**
30
116
* Schroedinger video preset table. Ensure that this tables matches up correctly
31
 
* with the ff_dirac_schro_video_format_info table in libdirac_libschro.c.
 
117
* with the ff_schro_video_format_info table.
32
118
*/
33
119
static const SchroVideoFormatEnum ff_schro_video_formats[]={
34
120
    SCHRO_VIDEO_FORMAT_CUSTOM     ,
55
141
    unsigned int num_formats = sizeof(ff_schro_video_formats) /
56
142
                               sizeof(ff_schro_video_formats[0]);
57
143
 
58
 
    unsigned int idx = ff_dirac_schro_get_video_format_idx (avccontext);
 
144
    unsigned int idx = get_video_format_idx(avccontext);
59
145
 
60
146
    return (idx < num_formats) ? ff_schro_video_formats[idx] :
61
147
                                 SCHRO_VIDEO_FORMAT_CUSTOM;
78
164
    return -1;
79
165
}
80
166
 
81
 
static void FreeSchroFrame(SchroFrame *frame, void *priv)
 
167
static void free_schro_frame(SchroFrame *frame, void *priv)
82
168
{
83
169
    AVPicture *p_pic = priv;
84
170
 
110
196
    p_frame->format = schro_frame_fmt;
111
197
    p_frame->width  = y_width;
112
198
    p_frame->height = y_height;
113
 
    schro_frame_set_free_callback(p_frame, FreeSchroFrame, (void *)p_pic);
 
199
    schro_frame_set_free_callback(p_frame, free_schro_frame, (void *)p_pic);
114
200
 
115
201
    for (i = 0; i < 3; ++i) {
116
202
        p_frame->components[i].width  = i ? uv_width : y_width;