]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/utils.c
check compression_type to assign audio codec
[ffmpeg] / libavcodec / utils.c
index 3b194899b35806825f2eedc6c23cffd1494ed476..af414c0096d42ad79657247a4f8a43b6a70adfc1 100644 (file)
@@ -171,6 +171,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
     case PIX_FMT_YUVJ420P:
     case PIX_FMT_YUVJ422P:
     case PIX_FMT_YUVJ444P:
+    case PIX_FMT_YUVA420P:
         w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
         h_align= 16;
         break;
@@ -265,7 +266,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
         buf->last_pic_num= *picture_number;
     }else{
         int h_chroma_shift, v_chroma_shift;
-        int pixel_size, size[3];
+        int pixel_size, size[4];
         AVPicture picture;
 
         avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
@@ -290,16 +291,17 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
         size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
         size[0] = picture.linesize[0] * h;
         size[1] -= size[0];
+        size[2] = size[3] = 0;
         if(picture.data[2])
             size[1]= size[2]= size[1]/2;
-        else
-            size[2]= 0;
+        if(picture.data[3])
+            size[3] = picture.linesize[3] * h;
 
         buf->last_pic_num= -256*256*256*64;
         memset(buf->base, 0, sizeof(buf->base));
         memset(buf->data, 0, sizeof(buf->data));
 
-        for(i=0; i<3 && size[i]; i++){
+        for(i=0; i<4 && size[i]; i++){
             const int h_shift= i==0 ? 0 : h_chroma_shift;
             const int v_shift= i==0 ? 0 : v_chroma_shift;
 
@@ -351,7 +353,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
 
     FFSWAP(InternalBuffer, *buf, *last);
 
-    for(i=0; i<3; i++){
+    for(i=0; i<4; i++){
         pic->data[i]=NULL;
 //        pic->base[i]=NULL;
     }
@@ -753,6 +755,7 @@ static const AVOption options[]={
 {"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
 {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
 {"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"},
+{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
 {NULL},
 };
 
@@ -959,8 +962,7 @@ int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *sa
             return -1;
         }
         if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
-        *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
-        *frame_size_ptr < buf_size){
+        *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){
             av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
             return -1;
         }
@@ -1073,6 +1075,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
     char buf1[32];
     char channels_str[100];
     int bitrate;
+    AVRational display_aspect_ratio;
 
     if (encode)
         p = avcodec_find_encoder(enc->codec_id);
@@ -1123,6 +1126,14 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      ", %dx%d",
                      enc->width, enc->height);
+            av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
+                      enc->width*enc->sample_aspect_ratio.num,
+                      enc->height*enc->sample_aspect_ratio.den,
+                      1024*1024);
+            snprintf(buf + strlen(buf), buf_size - strlen(buf),
+                     " [PAR %d:%d DAR %d:%d]",
+                     enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den,
+                     display_aspect_ratio.num, display_aspect_ratio.den);
             if(av_log_level >= AV_LOG_DEBUG){
                 int g= ff_gcd(enc->time_base.num, enc->time_base.den);
                 snprintf(buf + strlen(buf), buf_size - strlen(buf),