Changeset 25448
- Timestamp:
- 05/11/08 08:09:54 (5 days ago)
- Files:
-
- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp (modified) (1 diff)
- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp (modified) (2 diffs)
- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/QTStructs.h (modified) (1 diff)
- haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp
r25444 r25448 458 458 // Hmm 16bit format 32 bit FourCC. 459 459 theAudio.compression = aSoundDescription.basefields.DataFormat; 460 // theAudio.compression = aSoundDescription.desc.CompressionID;461 460 462 461 theAudio.NoOfChannels = aSoundDescription.desc.NoOfChannels; 463 462 theAudio.SampleSize = aSoundDescription.desc.SampleSize; 464 463 theAudio.SampleRate = aSoundDescription.desc.SampleRate / 65536; // Convert from fixed point decimal to float 465 theAudio.PacketSize = uint32((theAudio.SampleRate * theAudio.NoOfChannels * theAudio.SampleSize) / 8); 464 465 if (aSoundDescription.bytesPerFrame == 0) { 466 // XXX probably not right 467 theAudio.FrameSize = aSoundDescription.desc.SampleSize / 8; 468 } else { 469 theAudio.FrameSize = aSoundDescription.bytesPerFrame; 470 } 471 472 if (aSoundDescription.bytesPerPacket == 0) { 473 theAudio.BufferSize = uint32((theAudio.SampleSize * theAudio.NoOfChannels * theAudio.FrameSize) / 8); 474 } else { 475 theAudio.BufferSize = aSoundDescription.bytesPerPacket; 476 } 477 478 theAudio.BitRate = theAudio.SampleSize * theAudio.NoOfChannels * theAudio.SampleRate; 466 479 467 480 theAudio.theVOL = aSoundDescription.theVOL; haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp
r17893 r25448 817 817 Read(&aSoundDescriptionV1->desc.SampleRate); 818 818 819 if (aSoundDescriptionV1->desc.Version == 1) { 819 if ((aSoundDescriptionV1->desc.Version == 1) && (aSoundDescriptionV1->basefields.DataFormat != AUDIO_IMA4)) { 820 printf("V1 Sound Description Found\n"); 820 821 Read(&(aSoundDescriptionV1->samplesPerPacket)); 821 822 Read(&(aSoundDescriptionV1->bytesPerPacket)); … … 825 826 } else { 826 827 // Calculate? 827 aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; 828 if (aSoundDescriptionV1->basefields.DataFormat == 'ima4') { 829 aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 64 / 34; 828 if (aSoundDescriptionV1->basefields.DataFormat == AUDIO_IMA4) { 829 printf("Calculating IMA4 Sound Description\n"); 830 aSoundDescriptionV1->samplesPerPacket = 64; 831 aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 34; 832 833 aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; 834 aSoundDescriptionV1->bytesPerPacket = 64 * aSoundDescriptionV1->bytesPerFrame; 830 835 } else { 836 printf("Calculating Sound Description\n"); 837 aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; 831 838 aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * aSoundDescriptionV1->bytesPerSample; 832 }833 aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize;834 aSoundDescriptionV1->samplesPerPacket = aSoundDescriptionV1->desc.PacketSize / aSoundDescriptionV1->bytesPerFrame;839 aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize; 840 aSoundDescriptionV1->samplesPerPacket = aSoundDescriptionV1->desc.PacketSize / aSoundDescriptionV1->bytesPerFrame; 841 } 835 842 } 836 843 haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/QTStructs.h
r18488 r25448 106 106 struct AudioMetaData 107 107 { 108 uint32 compression; // compression used108 uint32 compression; // compression type used 109 109 uint16 NoOfChannels; // 1 = mono, 2 = stereo 110 110 uint16 SampleSize; // bits per sample 111 float SampleRate; // Samples per second (OR Frames per second) 112 uint32 PacketSize; // (Sample Rate * NoOfchannels * SampleSize)/8 = bytes per second 111 float SampleRate; // Samples per second 112 uint32 BufferSize; // (Sample Rate * NoOfchannels * SampleSize) / 8 = bytes per second 113 uint32 FrameSize; // Size of a Frame (NoOfChannels * SampleSize) / 8 114 float BitRate; // Bitrate of audio 113 115 uint8 *theVOL; 114 116 size_t VOLSize; haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp
r25444 r25448 35 35 #include "mov_reader.h" 36 36 37 //#define TRACE_MOV_READER37 #define TRACE_MOV_READER 38 38 #ifdef TRACE_MOV_READER 39 39 #define TRACE printf … … 137 137 movReader::AllocateCookie(int32 streamNumber, void **_cookie) 138 138 { 139 uint32 codecID; 140 139 141 mov_cookie *cookie = new mov_cookie; 140 142 *_cookie = cookie; … … 172 174 return B_ERROR; 173 175 } 176 177 codecID = B_BENDIAN_TO_HOST_INT32(audio_format->compression); 174 178 175 179 cookie->frame_count = theFileReader->getAudioFrameCount(cookie->stream); … … 192 196 cookie->frames_per_sec_scale = 1; 193 197 TRACE("bytes_per_sec_rate %ld, bytes_per_sec_scale %ld (using rate)\n", cookie->bytes_per_sec_rate, cookie->bytes_per_sec_scale); 194 } else if (audio_format-> PacketSize) {195 cookie->bytes_per_sec_rate = audio_format-> PacketSize;198 } else if (audio_format->BufferSize) { 199 cookie->bytes_per_sec_rate = audio_format->BufferSize; 196 200 cookie->bytes_per_sec_scale = 1; 197 cookie->frames_per_sec_rate = audio_format-> PacketSize * 8 / audio_format->SampleSize / audio_format->NoOfChannels;201 cookie->frames_per_sec_rate = audio_format->BufferSize * 8 / audio_format->SampleSize / audio_format->NoOfChannels; 198 202 cookie->frames_per_sec_scale = 1; 199 203 TRACE("bytes_per_sec_rate %ld, bytes_per_sec_scale %ld (using PacketSize)\n", cookie->bytes_per_sec_rate, cookie->bytes_per_sec_scale); … … 260 264 } 261 265 266 format->u.raw_audio.byte_order = B_MEDIA_BIG_ENDIAN; 267 268 if (audio_format->SampleSize <= 8) 269 format->u.raw_audio.format = B_AUDIO_FORMAT_UINT8; 270 else if (audio_format->SampleSize <= 16) 271 format->u.raw_audio.format = B_AUDIO_FORMAT_INT16; 272 else if (audio_format->SampleSize <= 24) 273 format->u.raw_audio.format = B_AUDIO_FORMAT_INT24; 274 else if (audio_format->SampleSize <= 32) 275 format->u.raw_audio.format = B_AUDIO_FORMAT_INT32; 276 else { 277 ERROR("movReader::AllocateCookie: unhandled bits per sample %d\n", audio_format->SampleSize); 278 return B_ERROR; 279 } 280 281 format->u.encoded_audio.frame_size = audio_format->FrameSize; 282 format->u.encoded_audio.output.buffer_size = audio_format->BufferSize; 283 284 TRACE("compression "); 285 262 286 switch (audio_format->compression) { 263 287 case AUDIO_MS_PCM02: … … 281 305 break; 282 306 case AUDIO_IMA4: 283 307 TRACE("IMA4\n"); 308 format->u.encoded_audio.bit_rate = audio_format->BitRate; 309 format->u.encoded_audio.output.frame_rate = cookie->frames_per_sec_rate / cookie->frames_per_sec_scale;; 310 format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels; 311 break; 284 312 default: 285 TRACE("OTHER \n");313 TRACE("OTHER %s\n",(char *)(&codecID)); 286 314 format->u.encoded_audio.bit_rate = 8 * cookie->frames_per_sec_rate / cookie->frames_per_sec_scale; 287 315 format->u.encoded_audio.output.frame_rate = cookie->frames_per_sec_rate / cookie->frames_per_sec_scale; … … 291 319 } 292 320 293 // this doesn't seem to work (it's not even a fourcc) 294 format->user_data_type = B_CODEC_TYPE_INFO; 295 *(uint32 *)format->user_data = audio_format->compression; format->user_data[4] = 0; 321 TRACE("Audio NoOfChannels %d, SampleSize %d, SampleRate %f, FrameSize %ld\n",audio_format->NoOfChannels, audio_format->SampleSize, audio_format->SampleRate, audio_format->FrameSize); 322 323 TRACE("Audio frame_rate %f, channel_count %ld, format %ld, buffer_size %ld, frame_size %ld, bit_rate %f\n", 324 format->u.encoded_audio.output.frame_rate, format->u.encoded_audio.output.channel_count, format->u.encoded_audio.output.format,format->u.encoded_audio.output.buffer_size, format->u.encoded_audio.frame_size, format->u.encoded_audio.bit_rate); 296 325 297 326 // Some codecs have additional setup data that they need, put it in metadata … … 299 328 const void *data = audio_format->theVOL; 300 329 if (size > 0) { 330 TRACE("VOL SIZE %ld\n", size); 301 331 format->SetMetaData(data, size); 302 332 } 303 304 #ifdef TRACE_MOV_READER305 uint8 *p = 18 + (uint8 *)data;306 TRACE("extra_data: %ld: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",307 size - 18, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]);308 #endif309 333 310 334 return B_OK; … … 318 342 return B_ERROR; 319 343 } 344 345 codecID = B_BENDIAN_TO_HOST_INT32(video_format->compression); 320 346 321 347 cookie->audio = false; … … 341 367 TRACE("frame_count %Ld\n", cookie->frame_count); 342 368 TRACE("duration %.6f (%Ld)\n", cookie->duration / 1E6, cookie->duration); 343 TRACE("compression %s\n", (char *)(& video_format->compression));369 TRACE("compression %s\n", (char *)(&codecID)); 344 370 345 371 description.family = B_QUICKTIME_FORMAT_FAMILY;
