Merge commit 'c3311d472a7528c67f76d0d061704ae70a99b32e'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 18 May 2014 12:14:33 +0000 (14:14 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 18 May 2014 12:14:33 +0000 (14:14 +0200)
* commit 'c3311d472a7528c67f76d0d061704ae70a99b32e':
  avienc: sanitize variable naming in write_header()

Conflicts:
libavformat/avienc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/avienc.c

@@@ -152,10 -143,9 +152,10 @@@ static int avi_write_header(AVFormatCon
      AVIContext *avi = s->priv_data;
      AVIOContext *pb = s->pb;
      int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
-     AVCodecContext *stream, *video_enc;
+     AVCodecContext *video_enc;
      int64_t list1, list2, strh, strf;
      AVDictionaryEntry *t = NULL;
 +    int padding;
  
      if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
          av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
          avio_wl16(pb, 0); /* language */
          avio_wl32(pb, 0); /* initial frame */
  
-         ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
+         ff_parse_specific_params(enc, &au_byterate, &au_ssize, &au_scale);
  
-         if (   stream->codec_type == AVMEDIA_TYPE_VIDEO
-             && stream->codec_id != AV_CODEC_ID_XSUB
++        if (   enc->codec_type == AVMEDIA_TYPE_VIDEO
++            && enc->codec_id != AV_CODEC_ID_XSUB
 +            && au_byterate > 1000LL*au_scale) {
 +            au_byterate = 600;
 +            au_scale    = 1;
 +        }
-         avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
-         if (stream->codec_id == AV_CODEC_ID_XSUB)
++        avpriv_set_pts_info(st, 64, au_scale, au_byterate);
++        if (enc->codec_id == AV_CODEC_ID_XSUB)
 +            au_scale = au_byterate = 0;
 +
          avio_wl32(pb, au_scale); /* scale */
          avio_wl32(pb, au_byterate); /* rate */
 -        avpriv_set_pts_info(st, 64, au_scale, au_byterate);
  
          avio_wl32(pb, 0); /* start */
          /* remember this offset to fill later */
          avio_wl32(pb, -1); /* quality */
          avio_wl32(pb, au_ssize); /* sample size */
          avio_wl32(pb, 0);
-         avio_wl16(pb, stream->width);
-         avio_wl16(pb, stream->height);
+         avio_wl16(pb, enc->width);
+         avio_wl16(pb, enc->height);
          ff_end_tag(pb, strh);
  
-         if (stream->codec_type != AVMEDIA_TYPE_DATA) {
+         if (enc->codec_type != AVMEDIA_TYPE_DATA) {
 +            int ret;
 +            enum AVPixelFormat pix_fmt;
 +
              strf = ff_start_tag(pb, "strf");
-             switch (stream->codec_type) {
+             switch (enc->codec_type) {
              case AVMEDIA_TYPE_SUBTITLE:
                  /* XSUB subtitles behave like video tracks, other subtitles
                   * are not (yet) supported. */
-                 if (stream->codec_id != AV_CODEC_ID_XSUB)
+                 if (enc->codec_id != AV_CODEC_ID_XSUB)
                      break;
              case AVMEDIA_TYPE_VIDEO:
 -                ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0);
 +                /* WMP expects RGB 5:5:5 rawvideo in avi to have bpp set to 16. */
-                 if (  !stream->codec_tag
-                     && stream->codec_id == AV_CODEC_ID_RAWVIDEO
-                     && stream->pix_fmt == AV_PIX_FMT_RGB555LE
-                     && stream->bits_per_coded_sample == 15)
-                     stream->bits_per_coded_sample = 16;
-                 ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0, 0);
++                if (  !enc->codec_tag
++                    && enc->codec_id == AV_CODEC_ID_RAWVIDEO
++                    && enc->pix_fmt == AV_PIX_FMT_RGB555LE
++                    && enc->bits_per_coded_sample == 15)
++                    enc->bits_per_coded_sample = 16;
++                ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, 0);
 +                pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
-                                               stream->bits_per_coded_sample);
-                 if (   !stream->codec_tag
-                     && stream->codec_id == AV_CODEC_ID_RAWVIDEO
-                     && stream->pix_fmt != pix_fmt
-                     && stream->pix_fmt != AV_PIX_FMT_NONE)
++                                              enc->bits_per_coded_sample);
++                if (   !enc->codec_tag
++                    && enc->codec_id == AV_CODEC_ID_RAWVIDEO
++                    && enc->pix_fmt != pix_fmt
++                    && enc->pix_fmt != AV_PIX_FMT_NONE)
 +                    av_log(s, AV_LOG_ERROR, "%s rawvideo cannot be written to avi, output file will be unreadable\n",
-                           av_get_pix_fmt_name(stream->pix_fmt));
++                          av_get_pix_fmt_name(enc->pix_fmt));
                  break;
              case AVMEDIA_TYPE_AUDIO:
-                 if ((ret = ff_put_wav_header(pb, stream, 0)) < 0)
 -                if (ff_put_wav_header(pb, enc) < 0)
 -                    return -1;
++                if ((ret = ff_put_wav_header(pb, enc, 0)) < 0)
 +                    return ret;
                  break;
              default:
 -                return -1;
 +                av_log(s, AV_LOG_ERROR,
 +                    "Invalid or not supported codec type '%s' found in the input\n",
-                     (char *)av_x_if_null(av_get_media_type_string(stream->codec_type), "?"));
++                    (char *)av_x_if_null(av_get_media_type_string(enc->codec_type), "?"));
 +                return AVERROR(EINVAL);
              }
              ff_end_tag(pb, strf);
-             if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
+             if ((t = av_dict_get(st->metadata, "title", NULL, 0))) {
                  ff_riff_write_info_tag(s->pb, "strn", t->value);
                  t = NULL;
              }
-             if (stream->codec_id == AV_CODEC_ID_XSUB
++            if (enc->codec_id == AV_CODEC_ID_XSUB
 +            && (t = av_dict_get(s->streams[i]->metadata, "language", NULL, 0))) {
 +                const char* langstr = av_convert_lang_to(t->value, AV_LANG_ISO639_1);
 +                t = NULL;
 +                if (langstr) {
 +                    char* str = av_asprintf("Subtitle - %s-xx;02", langstr);
 +                    ff_riff_write_info_tag(s->pb, "strn", str);
 +                    av_free(str);
 +                }
 +            }
          }
  
          if (pb->seekable) {