summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_qt.c57
-rw-r--r--src/libffmpeg/libavcodec/svq3.c32
-rw-r--r--src/libw32dll/qt_decoder.c44
-rw-r--r--src/xine-engine/buffer.h13
4 files changed, 82 insertions, 64 deletions
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c
index ffd1748e6..ed3a2f99c 100644
--- a/src/demuxers/demux_qt.c
+++ b/src/demuxers/demux_qt.c
@@ -30,7 +30,7 @@
* build_frame_table
* free_qt_info
*
- * $Id: demux_qt.c,v 1.158 2003/05/07 01:19:03 tmmm Exp $
+ * $Id: demux_qt.c,v 1.159 2003/05/10 04:26:17 tmmm Exp $
*
*/
@@ -194,6 +194,9 @@ typedef union {
palette_entry_t palette[PALETTE_COUNT];
int depth;
int edit_list_compensation; /* special trick for edit lists */
+
+ unsigned char *properties_atom;
+ unsigned int properties_atom_size;
} video;
struct {
@@ -218,6 +221,9 @@ typedef union {
unsigned int bytes_per_frame;
unsigned int bytes_per_sample;
unsigned int samples_per_frame;
+
+ unsigned char *properties_atom;
+ unsigned int properties_atom_size;
} audio;
} properties_t;
@@ -249,10 +255,6 @@ typedef struct {
void *decoder_config;
int decoder_config_len;
- /* verbatim copy of the stsd atom */
- int stsd_size;
- unsigned char *stsd;
-
/****************************************/
/* temporary tables for loading a chunk */
@@ -603,7 +605,7 @@ qt_info *create_qt_info(void) {
/* release a qt_info structure and associated data */
void free_qt_info(qt_info *info) {
- int i;
+ int i, j;
if(info) {
if(info->traks) {
@@ -618,7 +620,9 @@ void free_qt_info(qt_info *info) {
free(info->traks[i].sample_to_chunk_table);
free(info->traks[i].time_to_sample_table);
free(info->traks[i].decoder_config);
- free(info->traks[i].stsd);
+ for (j = 0; j < info->traks[i].stsd_atoms_count; j++)
+ free(info->traks[i].stsd_atoms[j].video.properties_atom);
+ free(info->traks[i].stsd_atoms);
}
free(info->traks);
}
@@ -752,8 +756,6 @@ static qt_error parse_trak_atom (qt_trak *trak,
trak->flags = 0;
trak->decoder_config = NULL;
trak->decoder_config_len = 0;
- trak->stsd = NULL;
- trak->stsd_size = 0;
trak->stsd_atoms_count = 0;
trak->stsd_atoms = NULL;
@@ -838,12 +840,6 @@ static qt_error parse_trak_atom (qt_trak *trak,
hexdump (&trak_atom[i], current_atom_size);
#endif
- /* copy whole stsd atom so it can later be sent to the decoder */
- trak->stsd_size = current_atom_size;
- trak->stsd = xine_xmalloc(current_atom_size);
- memset (trak->stsd, 0, current_atom_size);
- memcpy (trak->stsd, &trak_atom[i], current_atom_size);
-
/* allocate space for each of the properties unions */
trak->stsd_atoms_count = BE_32(&trak_atom[i + 8]);
trak->stsd_atoms = xine_xmalloc(trak->stsd_atoms_count * sizeof(properties_t));
@@ -858,11 +854,19 @@ static qt_error parse_trak_atom (qt_trak *trak,
for (k = 0; k < trak->stsd_atoms_count; k++) {
current_stsd_atom_size = BE_32(&trak_atom[atom_pos - 4]);
+
if (trak->type == MEDIA_VIDEO) {
trak->stsd_atoms[k].video.media_id = k + 1;
trak->stsd_atoms[k].video.properties_offset = properties_offset;
+ /* copy the properties atom */
+ trak->stsd_atoms[k].video.properties_atom_size = current_stsd_atom_size - 4;
+ trak->stsd_atoms[k].video.properties_atom =
+ xine_xmalloc(trak->stsd_atoms[k].video.properties_atom_size);
+ memcpy(trak->stsd_atoms[k].video.properties_atom, &trak_atom[atom_pos],
+ trak->stsd_atoms[k].video.properties_atom_size);
+
/* initialize to sane values */
trak->stsd_atoms[k].video.width = 0;
trak->stsd_atoms[k].video.height = 0;
@@ -995,6 +999,13 @@ static qt_error parse_trak_atom (qt_trak *trak,
trak->stsd_atoms[k].audio.media_id = k + 1;
trak->stsd_atoms[k].audio.properties_offset = properties_offset;
+ /* copy the properties atom */
+ trak->stsd_atoms[k].audio.properties_atom_size = current_stsd_atom_size - 4;
+ trak->stsd_atoms[k].audio.properties_atom =
+ xine_xmalloc(trak->stsd_atoms[k].audio.properties_atom_size);
+ memcpy(trak->stsd_atoms[k].audio.properties_atom, &trak_atom[atom_pos],
+ trak->stsd_atoms[k].audio.properties_atom_size);
+
/* fetch audio parameters */
trak->stsd_atoms[k].audio.codec_fourcc =
ME_32(&trak_atom[atom_pos + 0x0]);
@@ -1345,7 +1356,8 @@ free_trak:
free(trak->sample_to_chunk_table);
free(trak->time_to_sample_table);
free(trak->decoder_config);
- free(trak->stsd);
+ for (i = 0; i < trak->stsd_atoms_count; i++)
+ free(trak->stsd_atoms[i].video.properties_atom);
free(trak->stsd_atoms);
return last_error;
@@ -1647,11 +1659,6 @@ static qt_error build_frame_table(qt_trak *trak,
atom_to_use = i;
trak->properties = &trak->stsd_atoms[atom_to_use];
- /* adjust the stsd atom as needed */
- memcpy(trak->stsd + 12,
- &trak->stsd[trak->properties->video.properties_offset],
- BE_32(&trak->stsd[trak->properties->video.properties_offset]));
-
free(media_id_counts);
} else {
@@ -2458,8 +2465,8 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) {
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->decoder_flags = BUF_FLAG_SPECIAL;
buf->decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
- buf->decoder_info[2] = video_trak->stsd_size;
- buf->decoder_info_ptr[2] = video_trak->stsd;
+ buf->decoder_info[2] = video_trak->properties->video.properties_atom_size;
+ buf->decoder_info_ptr[2] = video_trak->properties->video.properties_atom;
buf->size = 0;
buf->type = video_trak->properties->video.codec_buftype;
this->video_fifo->put (this->video_fifo, buf);
@@ -2495,8 +2502,8 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) {
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->decoder_flags = BUF_FLAG_SPECIAL;
buf->decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
- buf->decoder_info[2] = audio_trak->stsd_size;
- buf->decoder_info_ptr[2] = audio_trak->stsd;
+ buf->decoder_info[2] = audio_trak->properties->audio.properties_atom_size;
+ buf->decoder_info_ptr[2] = audio_trak->properties->audio.properties_atom;
buf->size = 0;
buf->type = audio_trak->properties->audio.codec_buftype;
this->audio_fifo->put (this->audio_fifo, buf);
diff --git a/src/libffmpeg/libavcodec/svq3.c b/src/libffmpeg/libavcodec/svq3.c
index 6d24a5c7d..0cd927956 100644
--- a/src/libffmpeg/libavcodec/svq3.c
+++ b/src/libffmpeg/libavcodec/svq3.c
@@ -18,17 +18,23 @@
*
* How to use this decoder:
* SVQ3 data is transported within Apple Quicktime files. Quicktime files
- * have stsd atoms to describe media trak properties. Sometimes the stsd
- * atom contains information that the decoder must know in order to function
- * properly. Such is the case with SVQ3. In order to get the best use out
- * of this decoder, the calling app must make the video stsd atom available
+ * have stsd atoms to describe media trak properties. A stsd atom for a
+ * video trak contains 1 or more ImageDescription atoms. These atoms begin
+ * with the 4-byte length of the atom followed by the codec fourcc. Some
+ * decoders need information in this atom to operate correctly. Such
+ * is the case with SVQ3. In order to get the best use out of this decoder,
+ * the calling app must make the SVQ3 ImageDescription atom available
* via the AVCodecContext's extradata[_size] field:
*
- * AVCodecContext.extradata = pointer to stsd, first characters are expected
- * to be 's', 't', 's', and 'd', NOT the atom length
- * AVCodecContext.extradata_size = size of stsd atom memory buffer (which
- * will be the same as the stsd atom size field from the QT file, minus 4
- * bytes since the length is missing.
+ * AVCodecContext.extradata = pointer to ImageDescription, first characters
+ * are expected to be 'S', 'V', 'Q', and '3', NOT the 4-byte atom length
+ * AVCodecContext.extradata_size = size of ImageDescription atom memory
+ * buffer (which will be the same as the ImageDescription atom size field
+ * from the QT file, minus 4 bytes since the length is missing)
+ *
+ * You will know you have these parameters passed correctly when the decoder
+ * correctly decodes this file:
+ * ftp://ftp.mplayerhq.hu/MPlayer/samples/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov
*
*/
@@ -667,12 +673,12 @@ static int svq3_decode_frame (AVCodecContext *avctx,
alloc_tables (h);
}
- if (avctx->extradata && avctx->extradata_size >= 115
- && !memcmp (avctx->extradata, "stsd", 4)) {
+ if (avctx->extradata && avctx->extradata_size >= 0x63
+ && !memcmp (avctx->extradata, "SVQ3", 4)) {
- uint8_t *stsd = (uint8_t *) avctx->extradata + 114;
+ uint8_t *stsd = (uint8_t *) avctx->extradata + 0x62;
- if ((*stsd >> 5) != 7 || avctx->extradata_size >= 118) {
+ if ((*stsd >> 5) != 7 || avctx->extradata_size >= 0x66) {
if ((*stsd >> 5) == 7) {
stsd += 3; /* skip width, height (12 bits each) */
diff --git a/src/libw32dll/qt_decoder.c b/src/libw32dll/qt_decoder.c
index dbcd6d0a8..38c014cc0 100644
--- a/src/libw32dll/qt_decoder.c
+++ b/src/libw32dll/qt_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: qt_decoder.c,v 1.19 2003/05/09 23:55:40 tmmm Exp $
+ * $Id: qt_decoder.c,v 1.20 2003/05/10 04:26:18 tmmm Exp $
*
* quicktime video/audio decoder plugin, using win32 dlls
* most of this code comes directly from MPlayer
@@ -366,10 +366,10 @@ static void qta_init_driver (qta_decoder_t *this, buf_element_t *buf) {
return;
}
- if ((buf->decoder_info[2] > 0x48) && (buf->decoder_info[2] != 0x74)) {
+ if ((buf->decoder_info[2] > 0x38) && (buf->decoder_info[2] != 0x64)) {
error = this->SoundConverterSetInfo (this->myConverter,
FOUR_CHAR_CODE('w','a','v','e'),
- ((unsigned char *)buf->decoder_info_ptr[2]) + 0x48);
+ ((unsigned char *)buf->decoder_info_ptr[2]) + 0x38);
#ifdef LOG
printf ("qt_audio: SoundConverterSetInfo:%i\n",error);
#endif
@@ -913,28 +913,28 @@ static void qtv_init_driver (qtv_decoder_t *this, buf_element_t *buf) {
#endif
{
- uint8_t *stdata = ((unsigned char *)buf->decoder_info_ptr[2]) + 20;
- int stdata_len = buf->decoder_info[2] - 24;
+ uint8_t *stdata = ((unsigned char *)buf->decoder_info_ptr[2]);
+ int stdata_len = buf->decoder_info[2];
id=malloc (8+stdata_len) ; /* trak->stdata_len); */
- id->idSize = 8+stdata_len;
+ id->idSize = 4+stdata_len;
id->cType = FOUR_CHAR_CODE('S','V','Q','3');
- id->version = BE_16 (stdata+ 8);
- id->revisionLevel = BE_16 (stdata+10);
- id->vendor = BE_32 (stdata+12);
- id->temporalQuality = BE_32 (stdata+16);
- id->spatialQuality = BE_32 (stdata+20);
- id->width = BE_16 (stdata+24);
- id->height = BE_16 (stdata+26);
- id->hRes = BE_32 (stdata+28);
- id->vRes = BE_32 (stdata+32);
- id->dataSize = BE_32 (stdata+36);
- id->frameCount = BE_16 (stdata+40);
- memcpy(&id->name,stdata+42,32);
- id->depth = BE_16 (stdata+74);
- id->clutID = BE_16 (stdata+76);
- if (stdata_len>78)
- memcpy (((char*)&id->clutID)+2, stdata+78, stdata_len-78);
+ id->version = BE_16 (stdata+0x08);
+ id->revisionLevel = BE_16 (stdata+0x0C);
+ id->vendor = BE_32 (stdata+0x10);
+ id->temporalQuality = BE_32 (stdata+0x14);
+ id->spatialQuality = BE_32 (stdata+0x18);
+ id->width = BE_16 (stdata+0x1C);
+ id->height = BE_16 (stdata+0x1E);
+ id->hRes = BE_32 (stdata+0x20);
+ id->vRes = BE_32 (stdata+0x24);
+ id->dataSize = BE_32 (stdata+0x28);
+ id->frameCount = BE_16 (stdata+0x2C);
+ memcpy(&id->name,stdata+0x2D,32);
+ id->depth = BE_16 (stdata+0x4E);
+ id->clutID = BE_16 (stdata+0x50);
+ if (stdata_len>0x56)
+ memcpy (((char*)&id->clutID)+2, stdata+0x52, stdata_len-0x52);
#ifdef LOG
printf ("qt_video: id (%d bytes)\n", stdata_len);
diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h
index ae9c30365..cb737a4ca 100644
--- a/src/xine-engine/buffer.h
+++ b/src/xine-engine/buffer.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: buffer.h,v 1.110 2003/04/30 08:49:40 heinchen Exp $
+ * $Id: buffer.h,v 1.111 2003/05/10 04:26:18 tmmm Exp $
*
*
* contents:
@@ -335,9 +335,14 @@ struct buf_element_s {
/*
* In a BUF_SPECIAL_STSD_ATOM buffer:
* decoder_info[1] = BUF_SPECIAL_STSD_ATOM
- * decoder_info[2] = size of the stsd atom
- * decoder_info_ptr[2] = pointer to stsd atom
- * binary-only quicktime decoders need this, sent by qt demuxer
+ * decoder_info[2] = size of the ImageDescription atom, minus the
+ * four length bytes at the beginning
+ * decoder_info_ptr[2] = pointer to ImageDescription atom, starting with
+ * the codec fourcc
+ * Some Quicktime decoders need information contained within the
+ * ImageDescription atom inside a Quicktime file's stsd atom. This
+ * special buffer carries the ImageDescription atom from the QT demuxer
+ * to an A/V decoder.
*/
#define BUF_SPECIAL_STSD_ATOM 5