~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/cljr.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-25 15:47:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080225154712-qvr11ekcea4c9ry8
Tags: 1.1.6-0.1ubuntu1
* Merge from debian-multimedia (LP: #120003), Ubuntu Changes:
 - For ffmpeg-related build-deps, remove cvs from package names.
 - Standards-Version 3.7.3
 - Maintainer Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Cirrus Logic AccuPak (CLJR) codec
3
3
 * Copyright (c) 2003 Alex Beregszaszi
4
4
 *
5
 
 * This library is free software; you can redistribute it and/or
 
5
 * This file is part of FFmpeg.
 
6
 *
 
7
 * FFmpeg is free software; you can redistribute it and/or
6
8
 * modify it under the terms of the GNU Lesser General Public
7
9
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
 
10
 * version 2.1 of the License, or (at your option) any later version.
9
11
 *
10
 
 * This library is distributed in the hope that it will be useful,
 
12
 * FFmpeg is distributed in the hope that it will be useful,
11
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
15
 * Lesser General Public License for more details.
14
16
 *
15
17
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 * License along with FFmpeg; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
20
 *
19
21
 */
20
 
 
 
22
 
21
23
/**
22
24
 * @file cljr.c
23
25
 * Cirrus Logic AccuPak codec.
24
26
 */
25
 
 
 
27
 
26
28
#include "avcodec.h"
27
29
#include "mpegvideo.h"
28
30
 
34
36
    GetBitContext gb;
35
37
} CLJRContext;
36
38
 
37
 
static int decode_frame(AVCodecContext *avctx, 
 
39
static int decode_frame(AVCodecContext *avctx,
38
40
                        void *data, int *data_size,
39
41
                        uint8_t *buf, int buf_size)
40
42
{
43
45
    AVFrame * const p= (AVFrame*)&a->picture;
44
46
    int x, y;
45
47
 
46
 
    *data_size = 0;
47
 
 
48
 
    /* special case for last picture */
49
 
    if (buf_size == 0) {
50
 
        return 0;
51
 
    }
52
 
 
53
48
    if(p->data[0])
54
49
        avctx->release_buffer(avctx, p);
55
50
 
56
51
    p->reference= 0;
57
52
    if(avctx->get_buffer(avctx, p) < 0){
58
 
        fprintf(stderr, "get_buffer() failed\n");
 
53
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
59
54
        return -1;
60
55
    }
61
56
    p->pict_type= I_TYPE;
68
63
        uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ];
69
64
        uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ];
70
65
        for(x=0; x<avctx->width; x+=4){
71
 
            luma[3] = get_bits(&a->gb, 5) << 3;
72
 
            luma[2] = get_bits(&a->gb, 5) << 3;
73
 
            luma[1] = get_bits(&a->gb, 5) << 3;
74
 
            luma[0] = get_bits(&a->gb, 5) << 3;
75
 
            luma+= 4;
76
 
            *(cb++) = get_bits(&a->gb, 6) << 2;
77
 
            *(cr++) = get_bits(&a->gb, 6) << 2;
 
66
                luma[3] = get_bits(&a->gb, 5) << 3;
 
67
            luma[2] = get_bits(&a->gb, 5) << 3;
 
68
            luma[1] = get_bits(&a->gb, 5) << 3;
 
69
            luma[0] = get_bits(&a->gb, 5) << 3;
 
70
            luma+= 4;
 
71
            *(cb++) = get_bits(&a->gb, 6) << 2;
 
72
            *(cr++) = get_bits(&a->gb, 6) << 2;
78
73
        }
79
74
    }
80
75
 
82
77
    *data_size = sizeof(AVPicture);
83
78
 
84
79
    emms_c();
85
 
    
 
80
 
86
81
    return buf_size;
87
82
}
88
83
 
99
94
    p->key_frame= 1;
100
95
 
101
96
    emms_c();
102
 
    
 
97
 
103
98
    align_put_bits(&a->pb);
104
99
    while(get_bit_count(&a->pb)&31)
105
100
        put_bits(&a->pb, 8, 0);
106
 
    
 
101
 
107
102
    size= get_bit_count(&a->pb)/32;
108
 
    
 
103
 
109
104
    return size*4;
110
105
}
111
106
#endif
120
115
static int decode_init(AVCodecContext *avctx){
121
116
 
122
117
    common_init(avctx);
123
 
    
 
118
 
124
119
    avctx->pix_fmt= PIX_FMT_YUV411P;
125
120
 
126
121
    return 0;
127
122
}
128
123
 
 
124
#if 0
129
125
static int encode_init(AVCodecContext *avctx){
130
126
 
131
127
    common_init(avctx);
132
 
    
133
 
    return 0;
134
 
}
135
 
 
136
 
static int decode_end(AVCodecContext *avctx){
137
 
 
138
 
    avcodec_default_free_buffers(avctx);
139
 
 
140
 
    return 0;
141
 
}
 
128
 
 
129
    return 0;
 
130
}
 
131
#endif
142
132
 
143
133
AVCodec cljr_decoder = {
144
134
    "cljr",
147
137
    sizeof(CLJRContext),
148
138
    decode_init,
149
139
    NULL,
150
 
    decode_end,
 
140
    NULL,
151
141
    decode_frame,
152
142
    CODEC_CAP_DR1,
153
143
};