comparison utils.c @ 2967:ef2149182f1c libavcodec

COSMETICS: Remove all trailing whitespace.
author diego
date Sat, 17 Dec 2005 18:14:38 +0000
parents 2c4753d27834
children c9f6a0946672
comparison
equal deleted inserted replaced
2966:564788471dd4 2967:ef2149182f1c
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public 17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software 18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22 /** 22 /**
23 * @file utils.c 23 * @file utils.c
24 * utils. 24 * utils.
25 */ 25 */
26 26
27 #include "avcodec.h" 27 #include "avcodec.h"
28 #include "dsputil.h" 28 #include "dsputil.h"
29 #include "mpegvideo.h" 29 #include "mpegvideo.h"
30 #include "integer.h" 30 #include "integer.h"
31 #include "opt.h" 31 #include "opt.h"
57 void avcodec_default_free_buffers(AVCodecContext *s); 57 void avcodec_default_free_buffers(AVCodecContext *s);
58 58
59 void *av_mallocz(unsigned int size) 59 void *av_mallocz(unsigned int size)
60 { 60 {
61 void *ptr; 61 void *ptr;
62 62
63 ptr = av_malloc(size); 63 ptr = av_malloc(size);
64 if (!ptr) 64 if (!ptr)
65 return NULL; 65 return NULL;
66 memset(ptr, 0, size); 66 memset(ptr, 0, size);
67 return ptr; 67 return ptr;
82 /** 82 /**
83 * realloc which does nothing if the block is large enough 83 * realloc which does nothing if the block is large enough
84 */ 84 */
85 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size) 85 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
86 { 86 {
87 if(min_size < *size) 87 if(min_size < *size)
88 return ptr; 88 return ptr;
89 89
90 *size= FFMAX(17*min_size/16 + 32, min_size); 90 *size= FFMAX(17*min_size/16 + 32, min_size);
91 91
92 return av_realloc(ptr, *size); 92 return av_realloc(ptr, *size);
93 } 93 }
94 94
102 */ 102 */
103 void *av_mallocz_static(unsigned int size) 103 void *av_mallocz_static(unsigned int size)
104 { 104 {
105 void *ptr = av_mallocz(size); 105 void *ptr = av_mallocz(size);
106 106
107 if(ptr){ 107 if(ptr){
108 array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1)); 108 array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));
109 if(!array_static) 109 if(!array_static)
110 return NULL; 110 return NULL;
111 array_static[last_static++] = ptr; 111 array_static[last_static++] = ptr;
112 } 112 }
196 #define INTERNAL_BUFFER_SIZE 32 196 #define INTERNAL_BUFFER_SIZE 32
197 197
198 #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1)) 198 #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
199 199
200 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ 200 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
201 int w_align= 1; 201 int w_align= 1;
202 int h_align= 1; 202 int h_align= 1;
203 203
204 switch(s->pix_fmt){ 204 switch(s->pix_fmt){
205 case PIX_FMT_YUV420P: 205 case PIX_FMT_YUV420P:
206 case PIX_FMT_YUV422: 206 case PIX_FMT_YUV422:
207 case PIX_FMT_UYVY422: 207 case PIX_FMT_UYVY422:
208 case PIX_FMT_YUV422P: 208 case PIX_FMT_YUV422P:
252 } 252 }
253 253
254 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){ 254 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
255 if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/4) 255 if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/4)
256 return 0; 256 return 0;
257 257
258 av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h); 258 av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
259 return -1; 259 return -1;
260 } 260 }
261 261
262 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ 262 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
275 if(s->internal_buffer==NULL){ 275 if(s->internal_buffer==NULL){
276 s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer)); 276 s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer));
277 } 277 }
278 #if 0 278 #if 0
279 s->internal_buffer= av_fast_realloc( 279 s->internal_buffer= av_fast_realloc(
280 s->internal_buffer, 280 s->internal_buffer,
281 &s->internal_buffer_size, 281 &s->internal_buffer_size,
282 sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ 282 sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/
283 ); 283 );
284 #endif 284 #endif
285 285
286 buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; 286 buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
287 picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack 287 picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack
288 (*picture_number)++; 288 (*picture_number)++;
289 289
290 if(buf->base[0]){ 290 if(buf->base[0]){
291 pic->age= *picture_number - buf->last_pic_num; 291 pic->age= *picture_number - buf->last_pic_num;
292 buf->last_pic_num= *picture_number; 292 buf->last_pic_num= *picture_number;
293 }else{ 293 }else{
294 int h_chroma_shift, v_chroma_shift; 294 int h_chroma_shift, v_chroma_shift;
296 AVPicture picture; 296 AVPicture picture;
297 297
298 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); 298 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
299 299
300 avcodec_align_dimensions(s, &w, &h); 300 avcodec_align_dimensions(s, &w, &h);
301 301
302 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ 302 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
303 w+= EDGE_WIDTH*2; 303 w+= EDGE_WIDTH*2;
304 h+= EDGE_WIDTH*2; 304 h+= EDGE_WIDTH*2;
305 } 305 }
306 avpicture_fill(&picture, NULL, s->pix_fmt, w, h); 306 avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
333 buf->base[i]= av_malloc(size[i]+16); //FIXME 16 333 buf->base[i]= av_malloc(size[i]+16); //FIXME 16
334 if(buf->base[i]==NULL) return -1; 334 if(buf->base[i]==NULL) return -1;
335 memset(buf->base[i], 128, size[i]); 335 memset(buf->base[i], 128, size[i]);
336 336
337 // no edge if EDEG EMU or not planar YUV, we check for PAL8 redundantly to protect against a exploitable bug regression ... 337 // no edge if EDEG EMU or not planar YUV, we check for PAL8 redundantly to protect against a exploitable bug regression ...
338 if((s->flags&CODEC_FLAG_EMU_EDGE) || (s->pix_fmt == PIX_FMT_PAL8) || !size[2]) 338 if((s->flags&CODEC_FLAG_EMU_EDGE) || (s->pix_fmt == PIX_FMT_PAL8) || !size[2])
339 buf->data[i] = buf->base[i]; 339 buf->data[i] = buf->base[i];
340 else 340 else
341 buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN); 341 buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN);
342 } 342 }
343 pic->age= 256*256*256*64; 343 pic->age= 256*256*256*64;
430 430
431 static const char* context_to_name(void* ptr) { 431 static const char* context_to_name(void* ptr) {
432 AVCodecContext *avc= ptr; 432 AVCodecContext *avc= ptr;
433 433
434 if(avc && avc->codec && avc->codec->name) 434 if(avc && avc->codec && avc->codec->name)
435 return avc->codec->name; 435 return avc->codec->name;
436 else 436 else
437 return "NULL"; 437 return "NULL";
438 } 438 }
439 439
440 #define OFFSET(x) (int)&((AVCodecContext*)0)->x 440 #define OFFSET(x) (int)&((AVCodecContext*)0)->x
441 #define DEFAULT 0 //should be NAN but it doesnt work as its not a constant in glibc as required by ANSI/ISO C 441 #define DEFAULT 0 //should be NAN but it doesnt work as its not a constant in glibc as required by ANSI/ISO C
442 //these names are too long to be readable 442 //these names are too long to be readable
443 #define V AV_OPT_FLAG_VIDEO_PARAM 443 #define V AV_OPT_FLAG_VIDEO_PARAM
444 #define A AV_OPT_FLAG_AUDIO_PARAM 444 #define A AV_OPT_FLAG_AUDIO_PARAM
445 #define S AV_OPT_FLAG_SUBTITLE_PARAM 445 #define S AV_OPT_FLAG_SUBTITLE_PARAM
446 #define E AV_OPT_FLAG_ENCODING_PARAM 446 #define E AV_OPT_FLAG_ENCODING_PARAM
447 #define D AV_OPT_FLAG_DECODING_PARAM 447 #define D AV_OPT_FLAG_DECODING_PARAM
448 448
449 static AVOption options[]={ 449 static AVOption options[]={
450 {"bit_rate", NULL, OFFSET(bit_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|A|E}, 450 {"bit_rate", NULL, OFFSET(bit_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|A|E},
451 {"bit_rate_tolerance", NULL, OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, 451 {"bit_rate_tolerance", NULL, OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
752 s->level= FF_LEVEL_UNKNOWN; 752 s->level= FF_LEVEL_UNKNOWN;
753 s->me_penalty_compensation= 256; 753 s->me_penalty_compensation= 256;
754 s->pix_fmt= PIX_FMT_NONE; 754 s->pix_fmt= PIX_FMT_NONE;
755 s->frame_skip_cmp= FF_CMP_DCTMAX; 755 s->frame_skip_cmp= FF_CMP_DCTMAX;
756 s->nsse_weight= 8; 756 s->nsse_weight= 8;
757 757
758 s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS; 758 s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
759 s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS; 759 s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
760 s->palctrl = NULL; 760 s->palctrl = NULL;
761 s->reget_buffer= avcodec_default_reget_buffer; 761 s->reget_buffer= avcodec_default_reget_buffer;
762 } 762 }
763 763
764 /** 764 /**
765 * allocates a AVCodecContext and set it to defaults. 765 * allocates a AVCodecContext and set it to defaults.
766 * this can be deallocated by simply calling free() 766 * this can be deallocated by simply calling free()
767 */ 767 */
768 AVCodecContext *avcodec_alloc_context(void){ 768 AVCodecContext *avcodec_alloc_context(void){
769 AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); 769 AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
770 770
771 if(avctx==NULL) return NULL; 771 if(avctx==NULL) return NULL;
772 772
773 avcodec_get_context_defaults(avctx); 773 avcodec_get_context_defaults(avctx);
774 774
775 return avctx; 775 return avctx;
776 } 776 }
777 777
778 void avcodec_get_frame_defaults(AVFrame *pic){ 778 void avcodec_get_frame_defaults(AVFrame *pic){
779 memset(pic, 0, sizeof(AVFrame)); 779 memset(pic, 0, sizeof(AVFrame));
782 pic->key_frame= 1; 782 pic->key_frame= 1;
783 } 783 }
784 784
785 /** 785 /**
786 * allocates a AVPFrame and set it to defaults. 786 * allocates a AVPFrame and set it to defaults.
787 * this can be deallocated by simply calling free() 787 * this can be deallocated by simply calling free()
788 */ 788 */
789 AVFrame *avcodec_alloc_frame(void){ 789 AVFrame *avcodec_alloc_frame(void){
790 AVFrame *pic= av_malloc(sizeof(AVFrame)); 790 AVFrame *pic= av_malloc(sizeof(AVFrame));
791 791
792 if(pic==NULL) return NULL; 792 if(pic==NULL) return NULL;
793 793
794 avcodec_get_frame_defaults(pic); 794 avcodec_get_frame_defaults(pic);
795 795
796 return pic; 796 return pic;
797 } 797 }
798 798
799 int avcodec_open(AVCodecContext *avctx, AVCodec *codec) 799 int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
800 { 800 {
801 int ret= -1; 801 int ret= -1;
802 802
803 entangled_thread_counter++; 803 entangled_thread_counter++;
804 if(entangled_thread_counter != 1){ 804 if(entangled_thread_counter != 1){
805 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); 805 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
806 goto end; 806 goto end;
807 } 807 }
812 avctx->codec = codec; 812 avctx->codec = codec;
813 avctx->codec_id = codec->id; 813 avctx->codec_id = codec->id;
814 avctx->frame_number = 0; 814 avctx->frame_number = 0;
815 if (codec->priv_data_size > 0) { 815 if (codec->priv_data_size > 0) {
816 avctx->priv_data = av_mallocz(codec->priv_data_size); 816 avctx->priv_data = av_mallocz(codec->priv_data_size);
817 if (!avctx->priv_data) 817 if (!avctx->priv_data)
818 goto end; 818 goto end;
819 } else { 819 } else {
820 avctx->priv_data = NULL; 820 avctx->priv_data = NULL;
821 } 821 }
822 822
839 end: 839 end:
840 entangled_thread_counter--; 840 entangled_thread_counter--;
841 return ret; 841 return ret;
842 } 842 }
843 843
844 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 844 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
845 const short *samples) 845 const short *samples)
846 { 846 {
847 if(buf_size < FF_MIN_BUFFER_SIZE && 0){ 847 if(buf_size < FF_MIN_BUFFER_SIZE && 0){
848 av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n"); 848 av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
849 return -1; 849 return -1;
854 return ret; 854 return ret;
855 }else 855 }else
856 return 0; 856 return 0;
857 } 857 }
858 858
859 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 859 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
860 const AVFrame *pict) 860 const AVFrame *pict)
861 { 861 {
862 if(buf_size < FF_MIN_BUFFER_SIZE){ 862 if(buf_size < FF_MIN_BUFFER_SIZE){
863 av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n"); 863 av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
864 return -1; 864 return -1;
867 return -1; 867 return -1;
868 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){ 868 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
869 int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict); 869 int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict);
870 avctx->frame_number++; 870 avctx->frame_number++;
871 emms_c(); //needed to avoid an emms_c() call before every return; 871 emms_c(); //needed to avoid an emms_c() call before every return;
872 872
873 return ret; 873 return ret;
874 }else 874 }else
875 return 0; 875 return 0;
876 } 876 }
877 877
878 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, 878 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
879 const AVSubtitle *sub) 879 const AVSubtitle *sub)
880 { 880 {
881 int ret; 881 int ret;
882 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub); 882 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub);
883 avctx->frame_number++; 883 avctx->frame_number++;
884 return ret; 884 return ret;
885 } 885 }
886 886
887 /** 887 /**
888 * decode a frame. 888 * decode a frame.
889 * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes 889 * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes
890 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end 890 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
891 * @param buf_size the size of the buffer in bytes 891 * @param buf_size the size of the buffer in bytes
892 * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero 892 * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero
893 * @return -1 if error, otherwise return the number of 893 * @return -1 if error, otherwise return the number of
894 * bytes used. 894 * bytes used.
895 */ 895 */
896 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 896 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
897 int *got_picture_ptr, 897 int *got_picture_ptr,
898 uint8_t *buf, int buf_size) 898 uint8_t *buf, int buf_size)
899 { 899 {
900 int ret; 900 int ret;
901 901
902 *got_picture_ptr= 0; 902 *got_picture_ptr= 0;
903 if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height)) 903 if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
904 return -1; 904 return -1;
905 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ 905 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
906 ret = avctx->codec->decode(avctx, picture, got_picture_ptr, 906 ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
907 buf, buf_size); 907 buf, buf_size);
908 908
909 emms_c(); //needed to avoid an emms_c() call before every return; 909 emms_c(); //needed to avoid an emms_c() call before every return;
910 910
911 if (*got_picture_ptr) 911 if (*got_picture_ptr)
912 avctx->frame_number++; 912 avctx->frame_number++;
913 }else 913 }else
914 ret= 0; 914 ret= 0;
915 915
916 return ret; 916 return ret;
918 918
919 /* decode an audio frame. return -1 if error, otherwise return the 919 /* decode an audio frame. return -1 if error, otherwise return the
920 *number of bytes used. If no frame could be decompressed, 920 *number of bytes used. If no frame could be decompressed,
921 *frame_size_ptr is zero. Otherwise, it is the decompressed frame 921 *frame_size_ptr is zero. Otherwise, it is the decompressed frame
922 *size in BYTES. */ 922 *size in BYTES. */
923 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 923 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
924 int *frame_size_ptr, 924 int *frame_size_ptr,
925 uint8_t *buf, int buf_size) 925 uint8_t *buf, int buf_size)
926 { 926 {
927 int ret; 927 int ret;
928 928
929 *frame_size_ptr= 0; 929 *frame_size_ptr= 0;
930 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ 930 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
931 ret = avctx->codec->decode(avctx, samples, frame_size_ptr, 931 ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
932 buf, buf_size); 932 buf, buf_size);
933 avctx->frame_number++; 933 avctx->frame_number++;
934 }else 934 }else
935 ret= 0; 935 ret= 0;
936 return ret; 936 return ret;
944 const uint8_t *buf, int buf_size) 944 const uint8_t *buf, int buf_size)
945 { 945 {
946 int ret; 946 int ret;
947 947
948 *got_sub_ptr = 0; 948 *got_sub_ptr = 0;
949 ret = avctx->codec->decode(avctx, sub, got_sub_ptr, 949 ret = avctx->codec->decode(avctx, sub, got_sub_ptr,
950 (uint8_t *)buf, buf_size); 950 (uint8_t *)buf, buf_size);
951 if (*got_sub_ptr) 951 if (*got_sub_ptr)
952 avctx->frame_number++; 952 avctx->frame_number++;
953 return ret; 953 return ret;
954 } 954 }
1046 codec_name = "mpeg2ts"; 1046 codec_name = "mpeg2ts";
1047 } else if (enc->codec_name[0] != '\0') { 1047 } else if (enc->codec_name[0] != '\0') {
1048 codec_name = enc->codec_name; 1048 codec_name = enc->codec_name;
1049 } else { 1049 } else {
1050 /* output avi tags */ 1050 /* output avi tags */
1051 if( isprint(enc->codec_tag&0xFF) && isprint((enc->codec_tag>>8)&0xFF) 1051 if( isprint(enc->codec_tag&0xFF) && isprint((enc->codec_tag>>8)&0xFF)
1052 && isprint((enc->codec_tag>>16)&0xFF) && isprint((enc->codec_tag>>24)&0xFF)){ 1052 && isprint((enc->codec_tag>>16)&0xFF) && isprint((enc->codec_tag>>24)&0xFF)){
1053 snprintf(buf1, sizeof(buf1), "%c%c%c%c / 0x%04X", 1053 snprintf(buf1, sizeof(buf1), "%c%c%c%c / 0x%04X",
1054 enc->codec_tag & 0xff, 1054 enc->codec_tag & 0xff,
1055 (enc->codec_tag >> 8) & 0xff, 1055 (enc->codec_tag >> 8) & 0xff,
1056 (enc->codec_tag >> 16) & 0xff, 1056 (enc->codec_tag >> 16) & 0xff,
1057 (enc->codec_tag >> 24) & 0xff, 1057 (enc->codec_tag >> 24) & 0xff,
1058 enc->codec_tag); 1058 enc->codec_tag);
1111 snprintf(buf + strlen(buf), buf_size - strlen(buf), 1111 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1112 ", %d Hz, %s", 1112 ", %d Hz, %s",
1113 enc->sample_rate, 1113 enc->sample_rate,
1114 channels_str); 1114 channels_str);
1115 } 1115 }
1116 1116
1117 /* for PCM codecs, compute bitrate directly */ 1117 /* for PCM codecs, compute bitrate directly */
1118 switch(enc->codec_id) { 1118 switch(enc->codec_id) {
1119 case CODEC_ID_PCM_S32LE: 1119 case CODEC_ID_PCM_S32LE:
1120 case CODEC_ID_PCM_S32BE: 1120 case CODEC_ID_PCM_S32BE:
1121 case CODEC_ID_PCM_U32LE: 1121 case CODEC_ID_PCM_U32LE:
1165 if (enc->flags & CODEC_FLAG_PASS2) 1165 if (enc->flags & CODEC_FLAG_PASS2)
1166 snprintf(buf + strlen(buf), buf_size - strlen(buf), 1166 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1167 ", pass 2"); 1167 ", pass 2");
1168 } 1168 }
1169 if (bitrate != 0) { 1169 if (bitrate != 0) {
1170 snprintf(buf + strlen(buf), buf_size - strlen(buf), 1170 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1171 ", %d kb/s", bitrate / 1000); 1171 ", %d kb/s", bitrate / 1000);
1172 } 1172 }
1173 } 1173 }
1174 1174
1175 unsigned avcodec_version( void ) 1175 unsigned avcodec_version( void )
1205 1205
1206 void avcodec_default_free_buffers(AVCodecContext *s){ 1206 void avcodec_default_free_buffers(AVCodecContext *s){
1207 int i, j; 1207 int i, j;
1208 1208
1209 if(s->internal_buffer==NULL) return; 1209 if(s->internal_buffer==NULL) return;
1210 1210
1211 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){ 1211 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){
1212 InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i]; 1212 InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i];
1213 for(j=0; j<4; j++){ 1213 for(j=0; j<4; j++){
1214 av_freep(&buf->base[j]); 1214 av_freep(&buf->base[j]);
1215 buf->data[j]= NULL; 1215 buf->data[j]= NULL;
1216 } 1216 }
1217 } 1217 }
1218 av_freep(&s->internal_buffer); 1218 av_freep(&s->internal_buffer);
1219 1219
1220 s->internal_buffer_count=0; 1220 s->internal_buffer_count=0;
1221 } 1221 }
1222 1222
1223 char av_get_pict_type_char(int pict_type){ 1223 char av_get_pict_type_char(int pict_type){
1224 switch(pict_type){ 1224 switch(pict_type){
1225 case I_TYPE: return 'I'; 1225 case I_TYPE: return 'I';
1226 case P_TYPE: return 'P'; 1226 case P_TYPE: return 'P';
1227 case B_TYPE: return 'B'; 1227 case B_TYPE: return 'B';
1228 case S_TYPE: return 'S'; 1228 case S_TYPE: return 'S';
1229 case SI_TYPE:return 'i'; 1229 case SI_TYPE:return 'i';
1230 case SP_TYPE:return 'p'; 1230 case SP_TYPE:return 'p';
1231 default: return '?'; 1231 default: return '?';
1232 } 1232 }
1233 } 1233 }
1234 1234
1235 /* av_log API */ 1235 /* av_log API */
1245 #undef fprintf 1245 #undef fprintf
1246 if(print_prefix && avc) { 1246 if(print_prefix && avc) {
1247 fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), avc); 1247 fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), avc);
1248 } 1248 }
1249 #define fprintf please_use_av_log 1249 #define fprintf please_use_av_log
1250 1250
1251 print_prefix= strstr(fmt, "\n") != NULL; 1251 print_prefix= strstr(fmt, "\n") != NULL;
1252 1252
1253 vfprintf(stderr, fmt, vl); 1253 vfprintf(stderr, fmt, vl);
1254 } 1254 }
1255 1255
1256 static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; 1256 static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
1257 1257