OSDN Git Service

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