diff movenc.c @ 3759:27537074f2a9 libavformat

convert every muxer/demuxer to write/read sample_aspect_ratio from/to the corresponding AVStream instead of AVCodecContext
author aurel
date Sat, 23 Aug 2008 23:43:20 +0000
parents ae0885c44048
children f062deeedb8d
line wrap: on
line diff
--- a/movenc.c	Sat Aug 23 23:13:58 2008 +0000
+++ b/movenc.c	Sat Aug 23 23:43:20 2008 +0000
@@ -887,7 +887,7 @@
     return updateSize(pb, pos);
 }
 
-static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st)
 {
     int64_t duration = av_rescale_rnd(track->trackDuration, globalTimescale, track->timescale, AV_ROUND_UP);
     int version = duration < INT32_MAX ? 0 : 1;
@@ -930,7 +930,7 @@
 
     /* Track width and height, for visual only */
     if(track->enc->codec_type == CODEC_TYPE_VIDEO) {
-        double sample_aspect_ratio = av_q2d(track->enc->sample_aspect_ratio);
+        double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
         if(!sample_aspect_ratio) sample_aspect_ratio = 1;
         put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000);
         put_be32(pb, track->enc->height*0x10000);
@@ -978,12 +978,12 @@
     return 0x34;
 }
 
-static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track)
+static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st)
 {
     offset_t pos = url_ftell(pb);
     put_be32(pb, 0); /* size */
     put_tag(pb, "trak");
-    mov_write_tkhd_tag(pb, track);
+    mov_write_tkhd_tag(pb, track, st);
     if (track->mode == MODE_PSP || track->hasBframes)
         mov_write_edts_tag(pb, track);  // PSP Movies require edts box
     mov_write_mdia_tag(pb, track);
@@ -1350,7 +1350,7 @@
     //mov_write_iods_tag(pb, mov);
     for (i=0; i<mov->nb_streams; i++) {
         if(mov->tracks[i].entry > 0) {
-            mov_write_trak_tag(pb, &(mov->tracks[i]));
+            mov_write_trak_tag(pb, &(mov->tracks[i]), s->streams[i]);
         }
     }