]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/matroskaenc.c
a little bit more bitstream syntax for the residual
[ffmpeg] / libavformat / matroskaenc.c
index 742d4a35344b9f03dd5915629f91d615b0be2855..6f45f446c0ef20ca422890198723b4d513baadfd 100644 (file)
@@ -98,9 +98,9 @@ static void put_ebml_id(ByteIOContext *pb, unsigned int id)
 }
 
 /**
- * Write an EBML size meaning "unknown size"
+ * Write an EBML size meaning "unknown size".
  *
- * @param bytes The number of bytes the size should occupy. Maximum of 8.
+ * @param bytes The number of bytes the size should occupy (maximum: 8).
  */
 static void put_ebml_size_unknown(ByteIOContext *pb, int bytes)
 {
@@ -235,8 +235,8 @@ static void put_xiph_size(ByteIOContext *pb, int size)
  * that size.
  *
  * @param segment_offset The absolute offset to the position in the file
- *                       where the segment begins
- * @param numelements the maximum number of elements that will be indexed
+ *                       where the segment begins.
+ * @param numelements The maximum number of elements that will be indexed
  *                    by this seek head, 0 if unlimited.
  */
 static mkv_seekhead * mkv_start_seekhead(ByteIOContext *pb, offset_t segment_offset, int numelements)
@@ -284,7 +284,7 @@ static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, unsigned int elementid
  * be written at the location reserved for it. Otherwise, it is written
  * at the current location in the file.
  *
- * @return the file offset where the seekhead was written
+ * @return The file offset where the seekhead was written.
  */
 static offset_t mkv_write_seekhead(ByteIOContext *pb, mkv_seekhead *seekhead)
 {
@@ -386,7 +386,7 @@ static offset_t mkv_write_cues(ByteIOContext *pb, mkv_cues *cues, int num_tracks
     return currentpos;
 }
 
-static int put_xiph_codecpriv(ByteIOContext *pb, AVCodecContext *codec)
+static int put_xiph_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)
 {
     uint8_t *header_start[3];
     int header_len[3];
@@ -400,7 +400,7 @@ static int put_xiph_codecpriv(ByteIOContext *pb, AVCodecContext *codec)
 
     if (ff_split_xiph_headers(codec->extradata, codec->extradata_size,
                               first_header_size, header_start, header_len) < 0) {
-        av_log(codec, AV_LOG_ERROR, "Extradata corrupt.\n");
+        av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n");
         return -1;
     }
 
@@ -416,24 +416,24 @@ static int put_xiph_codecpriv(ByteIOContext *pb, AVCodecContext *codec)
 
 #define FLAC_STREAMINFO_SIZE 34
 
-static int put_flac_codecpriv(ByteIOContext *pb, AVCodecContext *codec)
+static int put_flac_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)
 {
     // if the extradata_size is greater than FLAC_STREAMINFO_SIZE,
     // assume that it's in Matroska's format already
     if (codec->extradata_size < FLAC_STREAMINFO_SIZE) {
-        av_log(codec, AV_LOG_ERROR, "Invalid FLAC extradata\n");
+        av_log(s, AV_LOG_ERROR, "Invalid FLAC extradata\n");
         return -1;
     } else if (codec->extradata_size == FLAC_STREAMINFO_SIZE) {
         // only the streaminfo packet
         put_byte(pb, 0);
         put_xiph_size(pb, codec->extradata_size);
-        av_log(codec, AV_LOG_ERROR, "Only one packet\n");
+        av_log(s, AV_LOG_ERROR, "Only one packet\n");
     }
     put_buffer(pb, codec->extradata, codec->extradata_size);
     return 0;
 }
 
-static void get_aac_sample_rates(AVCodecContext *codec, int *sample_rate, int *output_sample_rate)
+static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int *sample_rate, int *output_sample_rate)
 {
     static const int aac_sample_rates[] = {
         96000, 88200, 64000, 48000, 44100, 32000,
@@ -442,13 +442,13 @@ static void get_aac_sample_rates(AVCodecContext *codec, int *sample_rate, int *o
     int sri;
 
     if (codec->extradata_size < 2) {
-        av_log(codec, AV_LOG_WARNING, "no AAC extradata, unable to determine samplerate\n");
+        av_log(s, AV_LOG_WARNING, "No AAC extradata, unable to determine samplerate.\n");
         return;
     }
 
     sri = ((codec->extradata[0] << 1) & 0xE) | (codec->extradata[1] >> 7);
     if (sri > 12) {
-        av_log(codec, AV_LOG_WARNING, "AAC samplerate index out of bounds\n");
+        av_log(s, AV_LOG_WARNING, "AAC samplerate index out of bounds\n");
         return;
     }
     *sample_rate = aac_sample_rates[sri];
@@ -457,14 +457,14 @@ static void get_aac_sample_rates(AVCodecContext *codec, int *sample_rate, int *o
     if (codec->extradata_size == 5) {
         sri = (codec->extradata[4] >> 3) & 0xF;
         if (sri > 12) {
-            av_log(codec, AV_LOG_WARNING, "AAC output samplerate index out of bounds\n");
+            av_log(s, AV_LOG_WARNING, "AAC output samplerate index out of bounds\n");
             return;
         }
         *output_sample_rate = aac_sample_rates[sri];
     }
 }
 
-static int mkv_write_codecprivate(ByteIOContext *pb, AVCodecContext *codec, int native_id)
+static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec, int native_id)
 {
     ByteIOContext dyn_cp;
     uint8_t *codecpriv;
@@ -474,16 +474,16 @@ static int mkv_write_codecprivate(ByteIOContext *pb, AVCodecContext *codec, int
 
     if (native_id) {
         if (codec->codec_id == CODEC_ID_VORBIS || codec->codec_id == CODEC_ID_THEORA)
-            ret = put_xiph_codecpriv(&dyn_cp, codec);
+            ret = put_xiph_codecpriv(s, &dyn_cp, codec);
         else if (codec->codec_id == CODEC_ID_FLAC)
-            ret = put_flac_codecpriv(&dyn_cp, codec);
+            ret = put_flac_codecpriv(s, &dyn_cp, codec);
         else if (codec->extradata_size)
             put_buffer(&dyn_cp, codec->extradata, codec->extradata_size);
     } else if (codec->codec_type == CODEC_TYPE_VIDEO) {
         if (!codec->codec_tag)
             codec->codec_tag = codec_get_tag(codec_bmp_tags, codec->codec_id);
         if (!codec->codec_tag) {
-            av_log(codec, AV_LOG_ERROR, "no bmp codec id found");
+            av_log(s, AV_LOG_ERROR, "No bmp codec ID found.");
             ret = -1;
         }
 
@@ -493,7 +493,7 @@ static int mkv_write_codecprivate(ByteIOContext *pb, AVCodecContext *codec, int
         if (!codec->codec_tag)
             codec->codec_tag = codec_get_tag(codec_wav_tags, codec->codec_id);
         if (!codec->codec_tag) {
-            av_log(codec, AV_LOG_ERROR, "no wav codec id found");
+            av_log(s, AV_LOG_ERROR, "No wav codec ID found.");
             ret = -1;
         }
 
@@ -531,7 +531,7 @@ static int mkv_write_tracks(AVFormatContext *s)
             bit_depth = av_get_bits_per_sample_format(codec->sample_fmt);
 
         if (codec->codec_id == CODEC_ID_AAC)
-            get_aac_sample_rates(codec, &sample_rate, &output_sample_rate);
+            get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate);
 
         track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0);
         put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER     , i + 1);
@@ -543,7 +543,7 @@ static int mkv_write_tracks(AVFormatContext *s)
         else
             put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, "und");
 
-        // look for a codec id string specific to mkv to use,
+        // look for a codec ID string specific to mkv to use,
         // if none are found, use AVI codes
         for (j = 0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++) {
             if (ff_mkv_codec_tags[j].id == codec->codec_id) {
@@ -558,7 +558,7 @@ static int mkv_write_tracks(AVFormatContext *s)
                 put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
 
                 if (!native_id)
-                    // if there is no mkv-specific codec id, use VFW mode
+                    // if there is no mkv-specific codec ID, use VFW mode
                     put_ebml_string(pb, MATROSKA_ID_CODECID, MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC);
 
                 subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0);
@@ -598,7 +598,7 @@ static int mkv_write_tracks(AVFormatContext *s)
                 av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.");
                 break;
         }
-        ret = mkv_write_codecprivate(pb, codec, native_id);
+        ret = mkv_write_codecprivate(s, pb, codec, native_id);
         if (ret < 0) return ret;
 
         end_ebml_master(pb, track);