~ubuntu-dev/mplayer/ubuntu-feisty

« back to all changes in this revision

Viewing changes to libmpcodecs/vd_libmpeg2.c

  • Committer: Reinhard Tartler
  • Date: 2006-07-08 08:47:54 UTC
  • Revision ID: siretart@tauware.de-20060708084754-c3ff228cc9c2d8de
upgrade to pre8

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include "cpudetect.h"
31
31
 
 
32
typedef struct {
 
33
    mpeg2dec_t *mpeg2dec;
 
34
    int quant_store_idx;
 
35
    char *quant_store[3];
 
36
} vd_libmpeg2_ctx_t;
 
37
 
32
38
// to set/get/query special features/parameters
33
39
static int control(sh_video_t *sh,int cmd,void* arg,...){
34
 
    mpeg2dec_t * mpeg2dec = sh->context;
 
40
    vd_libmpeg2_ctx_t *context = sh->context;
 
41
    mpeg2dec_t * mpeg2dec = context->mpeg2dec;
35
42
    const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
36
43
 
37
44
    switch(cmd) {
52
59
 
53
60
// init driver
54
61
static int init(sh_video_t *sh){
 
62
    vd_libmpeg2_ctx_t *context;
55
63
    mpeg2dec_t * mpeg2dec;
56
64
//    const mpeg2_info_t * info;
57
65
    int accel;
75
83
    if(!mpeg2dec) return 0;
76
84
 
77
85
    mpeg2_custom_fbuf(mpeg2dec,1); // enable DR1
78
 
    
79
 
    sh->context=mpeg2dec;
 
86
 
 
87
    context = calloc(1, sizeof(vd_libmpeg2_ctx_t));
 
88
    context->mpeg2dec = mpeg2dec;
 
89
    sh->context = context;
80
90
 
81
91
    mpeg2dec->pending_buffer = 0;
82
92
    mpeg2dec->pending_length = 0;
86
96
 
87
97
// uninit driver
88
98
static void uninit(sh_video_t *sh){
89
 
    mpeg2dec_t * mpeg2dec = sh->context;
 
99
    int i;
 
100
    vd_libmpeg2_ctx_t *context = sh->context;
 
101
    mpeg2dec_t * mpeg2dec = context->mpeg2dec;
90
102
    if (mpeg2dec->pending_buffer) free(mpeg2dec->pending_buffer);
91
103
    mpeg2dec->decoder.convert=NULL;
92
104
    mpeg2dec->decoder.convert_id=NULL;
93
105
    mpeg2_close (mpeg2dec);
 
106
    for (i=0; i < 3; i++)
 
107
        free(context->quant_store[i]);
 
108
    free(sh->context);
94
109
}
95
110
 
96
111
static void draw_slice (void * _sh, uint8_t * const * src, unsigned int y){ 
97
112
    sh_video_t* sh = (sh_video_t*) _sh;
98
 
    mpeg2dec_t* mpeg2dec = sh->context;
 
113
    vd_libmpeg2_ctx_t *context = sh->context;
 
114
    mpeg2dec_t* mpeg2dec = context->mpeg2dec;
99
115
    const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
100
116
    int stride[3];
101
117
 
113
129
 
114
130
// decode a frame
115
131
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
116
 
    mpeg2dec_t * mpeg2dec = sh->context;
 
132
    vd_libmpeg2_ctx_t *context = sh->context;
 
133
    mpeg2dec_t * mpeg2dec = context->mpeg2dec;
117
134
    const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
118
135
    int drop_frame, framedrop=flags&3;
119
136
 
140
157
        int state=mpeg2_parse (mpeg2dec);
141
158
        int type, use_callback;
142
159
        mp_image_t* mpi_new;
 
160
        unsigned long pw, ph;
143
161
        
144
162
        switch(state){
145
163
        case STATE_BUFFER:
153
171
            }
154
172
            break;
155
173
        case STATE_SEQUENCE:
 
174
            pw = info->sequence->display_width * info->sequence->pixel_width;
 
175
            ph = info->sequence->display_height * info->sequence->pixel_height;
 
176
            if(ph) sh->aspect = (float) pw / (float) ph;
156
177
            // video parameters inited/changed, (re)init libvo:
157
178
            if (info->sequence->width >> 1 == info->sequence->chroma_width &&
158
179
                info->sequence->height >> 1 == info->sequence->chroma_height) {
200
221
            mpi_new->fields |= MP_IMGFIELD_ORDERED;
201
222
 
202
223
#ifdef MPEG12_POSTPROC
203
 
            if(!mpi_new->qscale){
204
 
                mpi_new->qstride=info->sequence->width>>4;
205
 
                mpi_new->qscale=malloc(mpi_new->qstride*(info->sequence->height>>4));
 
224
            mpi_new->qstride=info->sequence->width>>4;
 
225
            {
 
226
            char **p = &context->quant_store[type==PIC_FLAG_CODING_TYPE_B ?
 
227
                                        2 : (context->quant_store_idx ^= 1)];
 
228
            *p = realloc(*p, mpi_new->qstride*(info->sequence->height>>4));
 
229
            mpi_new->qscale = *p;
206
230
            }
207
231
            mpeg2dec->decoder.quant_store=mpi_new->qscale;
208
232
            mpeg2dec->decoder.quant_stride=mpi_new->qstride;