Revision be3564ed

View differences:

libavcodec/Makefile
17 17
      mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
18 18
      ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
19 19
      fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \
20
      vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o
20
      vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o
21 21

  
22 22
ifeq ($(AMR_NB),yes)
23 23
ifeq ($(AMR_NB_FIXED),yes)
libavcodec/allcodecs.c
110 110
    register_avcodec(&h264_decoder);
111 111
    register_avcodec(&vp3_decoder);
112 112
    register_avcodec(&asv1_decoder);
113
    register_avcodec(&vcr1_decoder);
113 114
    register_avcodec(&fourxm_decoder);
114 115
#ifdef CONFIG_AC3
115 116
    register_avcodec(&ac3_decoder);
libavcodec/avcodec.h
60 60
    CODEC_ID_ASV1,
61 61
    CODEC_ID_FFV1,
62 62
    CODEC_ID_4XM,
63
    CODEC_ID_VCR1,
63 64

  
64 65
    /* various pcm "codecs" */
65 66
    CODEC_ID_PCM_S16LE,
......
1257 1258
extern AVCodec huffyuv_encoder;
1258 1259
extern AVCodec h264_encoder;
1259 1260
extern AVCodec asv1_encoder;
1261
extern AVCodec vcr1_encoder;
1260 1262
extern AVCodec ffv1_encoder;
1261 1263

  
1262 1264
extern AVCodec h263_decoder;
......
1293 1295
extern AVCodec aac_decoder;
1294 1296
extern AVCodec mpeg4aac_decoder;
1295 1297
extern AVCodec asv1_decoder;
1298
extern AVCodec vcr1_decoder;
1296 1299
extern AVCodec ffv1_decoder;
1297 1300
extern AVCodec fourxm_decoder;
1298 1301
extern AVCodec ra_144_decoder;
libavcodec/vcr1.c
1
/*
2
 * ATI VCR1 codec
3
 * Copyright (c) 2003 Michael Niedermayer
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * 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
 */
19
 
20
/**
21
 * @file vcr1.c
22
 * ati vcr1 codec.
23
 */
24
 
25
#include "avcodec.h"
26
#include "mpegvideo.h"
27

  
28
//#undef NDEBUG
29
//#include <assert.h>
30

  
31
typedef struct VCR1Context{
32
    AVCodecContext *avctx;
33
    AVFrame picture;
34
    int delta[16];
35
    int offset[4];
36
} VCR1Context;
37

  
38
static int decode_frame(AVCodecContext *avctx, 
39
                        void *data, int *data_size,
40
                        uint8_t *buf, int buf_size)
41
{
42
    VCR1Context * const a = avctx->priv_data;
43
    AVFrame *picture = data;
44
    AVFrame * const p= (AVFrame*)&a->picture;
45
    uint8_t *bytestream= buf;
46
    int i, x, y;
47

  
48
    *data_size = 0;
49

  
50
    /* special case for last picture */
51
    if (buf_size == 0) {
52
        return 0;
53
    }
54

  
55
    if(p->data[0])
56
        avctx->release_buffer(avctx, p);
57

  
58
    p->reference= 0;
59
    if(avctx->get_buffer(avctx, p) < 0){
60
        fprintf(stderr, "get_buffer() failed\n");
61
        return -1;
62
    }
63
    p->pict_type= I_TYPE;
64
    p->key_frame= 1;
65

  
66
    for(i=0; i<16; i++){
67
        a->delta[i]= *(bytestream++);
68
        bytestream++;
69
    }
70
    
71
    for(y=0; y<avctx->height; y++){
72
        int offset;
73
        uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ];
74

  
75
        if((y&3) == 0){
76
            uint8_t *cb= &a->picture.data[1][ (y>>2)*a->picture.linesize[1] ];
77
            uint8_t *cr= &a->picture.data[2][ (y>>2)*a->picture.linesize[2] ];
78

  
79
            for(i=0; i<4; i++)
80
                a->offset[i]= *(bytestream++);
81

  
82
            offset= a->offset[0];
83
            for(x=0; x<avctx->width; x+=4){
84
                luma[0]=( offset += a->delta[ bytestream[2]&0xF ]);
85
                luma[1]=( offset += a->delta[ bytestream[2]>>4  ]);
86
                luma[2]=( offset += a->delta[ bytestream[0]&0xF ]);
87
                luma[3]=( offset += a->delta[ bytestream[0]>>4  ]);
88
                luma += 4;
89
                
90
                *(cb++) = bytestream[1];
91
                *(cr++) = bytestream[3];
92
                
93
                bytestream+= 4;
94
            }
95
        }else{
96
            offset= a->offset[y&3];
97

  
98
            for(x=0; x<avctx->width; x+=8){
99
                luma[0]=( offset += a->delta[ bytestream[2]&0xF ]);
100
                luma[1]=( offset += a->delta[ bytestream[2]>>4  ]);
101
                luma[2]=( offset += a->delta[ bytestream[3]&0xF ]);
102
                luma[3]=( offset += a->delta[ bytestream[3]>>4  ]);
103
                luma[4]=( offset += a->delta[ bytestream[0]&0xF ]);
104
                luma[5]=( offset += a->delta[ bytestream[0]>>4  ]);
105
                luma[6]=( offset += a->delta[ bytestream[1]&0xF ]);
106
                luma[7]=( offset += a->delta[ bytestream[1]>>4  ]);
107
                luma += 8;
108
                bytestream+= 4;
109
            }
110
        }
111
    }
112

  
113
    *picture= *(AVFrame*)&a->picture;
114
    *data_size = sizeof(AVPicture);
115

  
116
    emms_c();
117
    
118
    return buf_size;
119
}
120

  
121
#if 0
122
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
123
    VCR1Context * const a = avctx->priv_data;
124
    AVFrame *pict = data;
125
    AVFrame * const p= (AVFrame*)&a->picture;
126
    int size;
127
    int mb_x, mb_y;
128

  
129
    *p = *pict;
130
    p->pict_type= I_TYPE;
131
    p->key_frame= 1;
132

  
133
    emms_c();
134
    
135
    align_put_bits(&a->pb);
136
    while(get_bit_count(&a->pb)&31)
137
        put_bits(&a->pb, 8, 0);
138
    
139
    size= get_bit_count(&a->pb)/32;
140
    
141
    return size*4;
142
}
143
#endif
144

  
145
static void common_init(AVCodecContext *avctx){
146
    VCR1Context * const a = avctx->priv_data;
147

  
148
    avctx->coded_frame= (AVFrame*)&a->picture;
149
    a->avctx= avctx;
150
}
151

  
152
static int decode_init(AVCodecContext *avctx){
153
    VCR1Context * const a = avctx->priv_data;
154
    AVFrame *p= (AVFrame*)&a->picture;
155
    int i;
156
 
157
    common_init(avctx);
158
    
159
    avctx->pix_fmt= PIX_FMT_YUV410P;
160

  
161
    return 0;
162
}
163

  
164
static int encode_init(AVCodecContext *avctx){
165
    VCR1Context * const a = avctx->priv_data;
166
    int i;
167
 
168
    common_init(avctx);
169
    
170
    return 0;
171
}
172

  
173
static int decode_end(AVCodecContext *avctx){
174
    VCR1Context * const a = avctx->priv_data;
175

  
176
    avcodec_default_free_buffers(avctx);
177

  
178
    return 0;
179
}
180

  
181
AVCodec vcr1_decoder = {
182
    "vcr1",
183
    CODEC_TYPE_VIDEO,
184
    CODEC_ID_VCR1,
185
    sizeof(VCR1Context),
186
    decode_init,
187
    NULL,
188
    decode_end,
189
    decode_frame,
190
    CODEC_CAP_DR1,
191
};
192
#if 0
193
#ifdef CONFIG_ENCODERS
194

  
195
AVCodec vcr1_encoder = {
196
    "vcr1",
197
    CODEC_TYPE_VIDEO,
198
    CODEC_ID_VCR1,
199
    sizeof(VCR1Context),
200
    encode_init,
201
    encode_frame,
202
    //encode_end,
203
};
204

  
205
#endif //CONFIG_ENCODERS
206
#endif
libavformat/avienc.c
167 167
    { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
168 168
    { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
169 169
    { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
170
    { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
170 171
    { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
171 172
    { 0, 0 },
172 173
};

Also available in: Unified diff