diff options
Diffstat (limited to 'libavcodec/svq1enc.c')
-rw-r--r-- | libavcodec/svq1enc.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 9519d240b5..61c30d4cb7 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -2,20 +2,20 @@ * SVQ1 Encoder * Copyright (C) 2004 Mike Melanson <melanson@pcisys.net> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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.1 of the License, or (at your option) any later version. * - * Libav 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -32,12 +32,11 @@ #include "mpegvideo.h" #include "h263.h" #include "internal.h" +#include "libavutil/avassert.h" #include "svq1.h" #include "svq1enc_cb.h" -#undef NDEBUG -#include <assert.h> typedef struct SVQ1Context { @@ -95,7 +94,7 @@ static void svq1_write_header(SVQ1Context *s, int frame_type) /* output 5 unknown bits (2 + 2 + 1) */ put_bits(&s->pb, 5, 2); /* 2 needed by quicktime decoder */ - i= ff_match_2uint16(ff_svq1_frame_size_table, FF_ARRAY_ELEMS(ff_svq1_frame_size_table), s->frame_width, s->frame_height); + i= ff_match_2uint16((void*)ff_svq1_frame_size_table, FF_ARRAY_ELEMS(ff_svq1_frame_size_table), s->frame_width, s->frame_height); put_bits(&s->pb, 3, i); if (i == 7) @@ -176,7 +175,7 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *dec score= sqr - ((diff*(int64_t)diff)>>(level+3)); //FIXME 64bit slooow if(score < best_vector_score){ int mean= (diff + (size>>1)) >> (level+3); - assert(mean >-300 && mean<300); + av_assert2(mean >-300 && mean<300); mean= av_clip(mean, intra?0:-256, 255); best_vector_score= score; best_vector[stage]= i; @@ -184,7 +183,7 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *dec best_vector_mean= mean; } } - assert(best_vector_mean != -999); + av_assert0(best_vector_mean != -999); vector= codebook + stage*size*16 + best_vector[stage]*size; for(j=0; j<size; j++){ block[stage+1][j] = block[stage][j] - vector[j]; @@ -229,10 +228,10 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *dec put_bits(&s->reorder_pb[level], 1, split); if(!split){ - assert((best_mean >= 0 && best_mean<256) || !intra); - assert(best_mean >= -256 && best_mean<256); - assert(best_count >=0 && best_count<7); - assert(level<4 || best_count==0); + av_assert1((best_mean >= 0 && best_mean<256) || !intra); + av_assert1(best_mean >= -256 && best_mean<256); + av_assert1(best_count >=0 && best_count<7); + av_assert1(level<4 || best_count==0); /* output the encoding */ put_bits(&s->reorder_pb[level], @@ -242,7 +241,7 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *dec mean_vlc[best_mean][0]); for (i = 0; i < best_count; i++){ - assert(best_vector[i]>=0 && best_vector[i]<16); + av_assert2(best_vector[i]>=0 && best_vector[i]<16); put_bits(&s->reorder_pb[level], 4, best_vector[i]); } @@ -412,10 +411,10 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane s->m.pb= s->reorder_pb[5]; mx= motion_ptr[0]; my= motion_ptr[1]; - assert(mx>=-32 && mx<=31); - assert(my>=-32 && my<=31); - assert(pred_x>=-32 && pred_x<=31); - assert(pred_y>=-32 && pred_y<=31); + av_assert1(mx>=-32 && mx<=31); + av_assert1(my>=-32 && my<=31); + av_assert1(pred_x>=-32 && pred_x<=31); + av_assert1(pred_y>=-32 && pred_y<=31); ff_h263_encode_motion(&s->m, mx - pred_x, 1); ff_h263_encode_motion(&s->m, my - pred_y, 1); s->reorder_pb[5]= s->m.pb; @@ -505,11 +504,8 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, AVFrame temp; int i, ret; - if (!pkt->data && - (ret = av_new_packet(pkt, s->y_block_width*s->y_block_height*MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE) < 0)) { - av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); + if ((ret = ff_alloc_packet2(avctx, pkt, s->y_block_width*s->y_block_height*MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE) < 0)) return ret; - } if(avctx->pix_fmt != PIX_FMT_YUV410P){ av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n"); @@ -573,6 +569,10 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) av_freep(&s->motion_val8[i]); av_freep(&s->motion_val16[i]); } + if(s->current_picture.data[0]) + avctx->release_buffer(avctx, &s->current_picture); + if(s->last_picture.data[0]) + avctx->release_buffer(avctx, &s->last_picture); return 0; } |