OSDN Git Service

Change the fifo size from being statically tuned for a Mac Pro with 4 CPUs to dynamic...
[handbrake-jp/handbrake-jp-git.git] / contrib / patch-ffmpeg.patch
1 Index: configure
2 ===================================================================
3 --- configure   (revision 9814)
4 +++ configure   (working copy)
5 @@ -1095,7 +1095,7 @@
6        2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
7          mmx="no"
8          ;;
9 -      *20010315*) echo "BeBits gcc"
10 +      *20010315*|2.95.3*) echo "BeBits gcc"
11          add_cflags "-fno-expensive-optimizations"
12          ;;
13      esac
14 Index: libavformat/Makefile
15 ===================================================================
16 --- libavformat/Makefile        (revision 9814)
17 +++ libavformat/Makefile        (working copy)
18 @@ -69,6 +69,7 @@
19  OBJS-$(CONFIG_IMAGE2PIPE_MUXER)          += img2.o
20  OBJS-$(CONFIG_INGENIENT_DEMUXER)         += raw.o
21  OBJS-$(CONFIG_IPMOVIE_DEMUXER)           += ipmovie.o
22 +OBJS-$(CONFIG_IPOD_MUXER)                += movenc.o riff.o isom.o
23  OBJS-$(CONFIG_M4V_DEMUXER)               += raw.o
24  OBJS-$(CONFIG_M4V_MUXER)                 += raw.o
25  OBJS-$(CONFIG_MATROSKA_DEMUXER)          += matroskadec.o matroska.o riff.o
26 Index: libavformat/tcp.c
27 ===================================================================
28 --- libavformat/tcp.c   (revision 9814)
29 +++ libavformat/tcp.c   (working copy)
30 @@ -88,11 +88,13 @@
31                  break;
32          }
33  
34 +#ifndef __BEOS__
35          /* test error */
36          optlen = sizeof(ret);
37          getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
38          if (ret != 0)
39              goto fail;
40 +#endif
41      }
42      s->fd = fd;
43      return 0;
44 Index: libavformat/movenc.c
45 ===================================================================
46 --- libavformat/movenc.c        (revision 9814)
47 +++ libavformat/movenc.c        (working copy)
48 @@ -36,6 +36,7 @@
49  #define MODE_PSP 3 // example working PSP command line:
50  // ffmpeg -i testinput.avi  -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4
51  #define MODE_3G2 4
52 +#define MODE_IPOD 5
53  
54  typedef struct MOVIentry {
55      unsigned int flags, size;
56 @@ -54,6 +55,7 @@
57      long        time;
58      int64_t     trackDuration;
59      long        sampleCount;
60 +    long        sampleDuration;
61      long        sampleSize;
62      int         hasKeyframes;
63      int         hasBframes;
64 @@ -572,6 +574,18 @@
65      return tag;
66  }
67  
68 +static int mov_write_colr_tag(ByteIOContext *pb)
69 +{
70 +       put_be32( pb, 0x12 );
71 +       put_tag( pb, "colr" );
72 +       put_tag( pb, "nclc" );
73 +       put_be16( pb, 6 );
74 +       put_be16( pb, 1 );
75 +       put_be16( pb, 6 );
76 +       put_be32( pb, 0 );
77 +       return 0x12;
78 +}
79 +
80  static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track)
81  {
82      offset_t pos = url_ftell(pb);
83 @@ -621,9 +635,22 @@
84          mov_write_d263_tag(pb);
85      else if(track->enc->codec_id == CODEC_ID_SVQ3)
86          mov_write_svq3_tag(pb);
87 -    else if(track->enc->codec_id == CODEC_ID_H264)
88 -        mov_write_avcc_tag(pb, track);
89 +       else if(track->enc->codec_id == CODEC_ID_H264) {
90 +               mov_write_avcc_tag(pb, track);
91 +               if (track->mode == MODE_IPOD) {
92 +                       put_be32(pb, 0x1C); /* size ... reports as 28 in mp4box! */
93 +                       put_tag(pb, "uuid");
94 +                       put_be32(pb, 0x6B6840F2);
95 +                       put_be32(pb, 0x5F244FC5);
96 +                       put_be32(pb, 0xBA39A51B);
97 +                       put_be32(pb, 0xCF0323F3);
98 +                       put_be32(pb, 0x00000001);
99 +                       put_be32(pb, 0x0000039C); 
100 +               }
101 +       }
102  
103 +       mov_write_colr_tag(pb);
104 +
105      return updateSize (pb, pos);
106  }
107  
108 @@ -674,46 +701,18 @@
109      return atom_size;
110  }
111  
112 +/* TODO: */
113  /* Time to sample atom */
114  static int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track)
115  {
116 -    MOV_stts_t *stts_entries;
117 -    uint32_t entries = -1;
118 -    uint32_t atom_size;
119 -    int i;
120 -
121 -    if (track->enc->codec_type == CODEC_TYPE_AUDIO && !track->audio_vbr) {
122 -        stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */
123 -        stts_entries[0].count = track->sampleCount;
124 -        stts_entries[0].duration = 1;
125 -        entries = 1;
126 -    } else {
127 -        stts_entries = av_malloc(track->entry * sizeof(*stts_entries)); /* worst case */
128 -        for (i=0; i<track->entry; i++) {
129 -            int64_t duration = i + 1 == track->entry ?
130 -                track->trackDuration - track->cluster[i].dts + track->cluster[0].dts : /* readjusting */
131 -                track->cluster[i+1].dts - track->cluster[i].dts;
132 -            if (i && duration == stts_entries[entries].duration) {
133 -                stts_entries[entries].count++; /* compress */
134 -            } else {
135 -                entries++;
136 -                stts_entries[entries].duration = duration;
137 -                stts_entries[entries].count = 1;
138 -            }
139 -        }
140 -        entries++; /* last one */
141 -    }
142 -    atom_size = 16 + (entries * 8);
143 -    put_be32(pb, atom_size); /* size */
144 +    put_be32(pb, 0x18); /* size */
145      put_tag(pb, "stts");
146      put_be32(pb, 0); /* version & flags */
147 -    put_be32(pb, entries); /* entry count */
148 -    for (i=0; i<entries; i++) {
149 -        put_be32(pb, stts_entries[i].count);
150 -        put_be32(pb, stts_entries[i].duration);
151 -    }
152 -    av_free(stts_entries);
153 -    return atom_size;
154 +    put_be32(pb, 1); /* entry count */
155 +
156 +    put_be32(pb, track->sampleCount); /* sample count */
157 +    put_be32(pb, track->sampleDuration); /* sample duration */
158 +    return 0x18;
159  }
160  
161  static int mov_write_dref_tag(ByteIOContext *pb)
162 @@ -911,6 +910,10 @@
163      /* Track width and height, for visual only */
164      if(track->enc->codec_type == CODEC_TYPE_VIDEO) {
165          double sample_aspect_ratio = av_q2d(track->enc->sample_aspect_ratio);
166 +               if (track->mode == MODE_IPOD) {
167 +                       /* FIXME , I do not believe this is needed, bad assumption */
168 +                       sample_aspect_ratio = 1;
169 +               }
170          if( !sample_aspect_ratio ) sample_aspect_ratio = 1;
171          put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000);
172          put_be32(pb, track->enc->height*0x10000);
173 @@ -1322,6 +1325,8 @@
174      for (i=0; i<mov->nb_streams; i++) {
175          if(mov->tracks[i].entry <= 0) continue;
176  
177 +        mov->tracks[i].trackDuration =
178 +            (int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;
179          mov->tracks[i].time = mov->time;
180          mov->tracks[i].trackID = i+1;
181      }
182 @@ -1369,6 +1374,8 @@
183          put_tag(pb, "MSNV");
184      else if ( mov->mode == MODE_MP4 )
185          put_tag(pb, "isom");
186 +       else if ( mov->mode == MODE_IPOD )
187 +        put_tag(pb, "isom");
188      else
189          put_tag(pb, "qt  ");
190  
191 @@ -1380,6 +1387,8 @@
192          put_tag(pb, "3g2a");
193      else if ( mov->mode == MODE_PSP )
194          put_tag(pb, "MSNV");
195 +       else if ( mov->mode == MODE_IPOD )
196 +        put_tag(pb, "mp41");
197      else if ( mov->mode == MODE_MP4 )
198          put_tag(pb, "mp41");
199      else
200 @@ -1466,7 +1475,8 @@
201          else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3G2;
202          else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
203          else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
204 -
205 +               else if (!strcmp("ipod", s->oformat->name)) mov->mode = MODE_IPOD;
206 +               
207          mov_write_ftyp_tag(pb,s);
208          if ( mov->mode == MODE_PSP ) {
209              if ( s->nb_streams != 2 ) {
210 @@ -1487,6 +1497,7 @@
211          if(st->codec->codec_type == CODEC_TYPE_VIDEO){
212              track->tag = mov_find_video_codec_tag(s, track);
213              track->timescale = st->codec->time_base.den;
214 +            track->sampleDuration = st->codec->time_base.num;
215              av_set_pts_info(st, 64, 1, st->codec->time_base.den);
216              if (track->timescale > 100000)
217                  av_log(NULL, AV_LOG_WARNING,
218 @@ -1496,6 +1507,7 @@
219          }else if(st->codec->codec_type == CODEC_TYPE_AUDIO){
220              track->tag = mov_find_audio_codec_tag(s, track);
221              track->timescale = st->codec->sample_rate;
222 +            track->sampleDuration = st->codec->frame_size;
223              av_set_pts_info(st, 64, 1, st->codec->sample_rate);
224              if(!st->codec->frame_size){
225                  av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
226 @@ -1675,6 +1687,21 @@
227      .flags = AVFMT_GLOBALHEADER,
228  };
229  #endif
230 +#ifdef CONFIG_IPOD_MUXER
231 +AVOutputFormat ipod_muxer = {
232 +    "ipod",
233 +    "ipod mp4 format",
234 +    "application/mp4",
235 +    "mp4,m4v,ipod",
236 +    sizeof(MOVContext),
237 +    CODEC_ID_AAC,
238 +    CODEC_ID_MPEG4,
239 +    mov_write_header,
240 +    mov_write_packet,
241 +    mov_write_trailer,
242 +    .flags = AVFMT_GLOBALHEADER,
243 +};
244 +#endif
245  #ifdef CONFIG_PSP_MUXER
246  AVOutputFormat psp_muxer = {
247      "psp",
248 Index: libavformat/allformats.c
249 ===================================================================
250 --- libavformat/allformats.c    (revision 9814)
251 +++ libavformat/allformats.c    (working copy)
252 @@ -89,6 +89,9 @@
253      REGISTER_MUXDEMUX(IMAGE2PIPE, image2pipe);
254      REGISTER_DEMUXER (INGENIENT, ingenient);
255      REGISTER_DEMUXER (IPMOVIE, ipmovie);
256 +#ifdef CONFIG_IPOD_MUXER
257 +    REGISTER_MUXER   (IPOD, ipod);
258 +#endif
259      if (!ENABLE_NUT_DEMUXER) REGISTER_DEMUXER (LIBNUT, libnut);
260      REGISTER_MUXER   (LIBNUT, libnut);
261      REGISTER_MUXDEMUX(M4V, m4v);
262 Index: libavformat/allformats.h
263 ===================================================================
264 --- libavformat/allformats.h    (revision 9814)
265 +++ libavformat/allformats.h    (working copy)
266 @@ -142,6 +142,7 @@
267  extern AVOutputFormat image2pipe_muxer;
268  extern AVOutputFormat image_muxer;
269  extern AVOutputFormat imagepipe_muxer;
270 +extern AVOutputFormat ipod_muxer;
271  extern AVOutputFormat libnut_muxer;
272  extern AVOutputFormat m4v_muxer;
273  extern AVOutputFormat mjpeg_muxer;