*
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
DSPContext dsp;
}FFV1Context;
-static always_inline int fold(int diff, int bits){
+static av_always_inline int fold(int diff, int bits){
if(bits==8)
diff= (int8_t)diff;
else{
int i;
if(v){
- const int a= ABS(v);
+ const int a= FFABS(v);
const int e= av_log2(a);
put_rac(c, state+0, 0);
static inline void update_vlc_state(VlcState * const state, const int v){
int drift= state->drift;
int count= state->count;
- state->error_sum += ABS(v);
+ state->error_sum += FFABS(v);
drift += v;
if(count == 128){ //FIXME variable
return ret;
}
+#ifdef CONFIG_ENCODERS
static inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], int plane_index, int bits){
PlaneContext * const p= &s->plane[plane_index];
RangeCoder * const c= &s->c;
for(i=0; i<5; i++)
write_quant_table(c, f->quant_table[i]);
}
+#endif /* CONFIG_ENCODERS */
static int common_init(AVCodecContext *avctx){
FFV1Context *s = avctx->priv_data;
return 0;
}
+#ifdef CONFIG_ENCODERS
static int encode_init(AVCodecContext *avctx)
{
FFV1Context *s = avctx->priv_data;
int i;
- if(avctx->strict_std_compliance >FF_COMPLIANCE_EXPERIMENTAL){
- av_log(avctx, AV_LOG_ERROR, "this codec is under development, files encoded with it may not be decodeable with future versions!!!\n"
- "use vstrict=-2 / -strict -2 to use it anyway\n");
- return -1;
- }
-
common_init(avctx);
s->version=0;
return 0;
}
+#endif /* CONFIG_ENCODERS */
static void clear_state(FFV1Context *f){
}
}
+#ifdef CONFIG_ENCODERS
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
FFV1Context *f = avctx->priv_data;
RangeCoder * const c= &f->c;
return used_count + (put_bits_count(&f->pb)+7)/8;
}
}
+#endif /* CONFIG_ENCODERS */
-static void common_end(FFV1Context *s){
+static int common_end(AVCodecContext *avctx){
+ FFV1Context *s = avctx->priv_data;
int i;
for(i=0; i<s->plane_count; i++){
av_freep(&p->state);
}
-}
-
-static int encode_end(AVCodecContext *avctx)
-{
- FFV1Context *s = avctx->priv_data;
-
- common_end(s);
return 0;
}
p->pict_type= FF_I_TYPE; //FIXME I vs. P
if(get_rac(c, &keystate)){
p->key_frame= 1;
- read_header(f);
+ if(read_header(f) < 0)
+ return -1;
clear_state(f);
}else{
p->key_frame= 0;
}
+ if(!f->plane[0].state && !f->plane[0].vlc_state)
+ return -1;
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
sizeof(FFV1Context),
decode_init,
NULL,
- NULL,
+ common_end,
decode_frame,
CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
NULL
sizeof(FFV1Context),
encode_init,
encode_frame,
- encode_end,
+ common_end,
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGBA32, -1},
};
#endif