1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*****************************************************************
* gmerlin-avdecoder - a general purpose multimedia decoding library
*
* Copyright (c) 2001 - 2012 Members of the Gmerlin project
* gmerlin-general@lists.sourceforge.net
* http://gmerlin.sourceforge.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *****************************************************************/
#include <avdec_private.h>
#include <qt.h>
#include <stdio.h>
#define LOG_DOMAIN "qt_atom"
/*
uint64_t size;
uint64_t start_position;
uint32_t fourcc;
uint8_t version;
uint32_t flags;
*/
int bgav_qt_atom_read_header(bgav_input_context_t * input,
qt_atom_header_t * h)
{
uint32_t tmp_32;
h->start_position = input->position;
if(!bgav_input_read_32_be(input, &tmp_32))
return 0;
h->size = tmp_32;
if(!bgav_input_read_fourcc(input, &h->fourcc))
return 0;
if(tmp_32 == 1) /* 64 bit atom */
{
if(!bgav_input_read_64_be(input, &h->size))
return 0;
}
return 1;
}
void bgav_qt_atom_skip(bgav_input_context_t * input,
qt_atom_header_t * h)
{
int64_t bytes_to_skip = h->size - (input->position - h->start_position);
if(bytes_to_skip > 0)
bgav_input_skip(input, bytes_to_skip);
}
void bgav_qt_atom_skip_unknown(bgav_input_context_t * input,
qt_atom_header_t * h, uint32_t parent)
{
char tmp_string[128];
if(!parent)
gavl_log(GAVL_LOG_DEBUG, LOG_DOMAIN,
"Unknown atom [%c%c%c%c] at toplevel",
(h->fourcc & 0xFF000000) >> 24,
(h->fourcc & 0x00FF0000) >> 16,
(h->fourcc & 0x0000FF00) >> 8,
(h->fourcc & 0x000000FF));
else
{
sprintf(tmp_string, "%" PRId64, h->size);
gavl_log(GAVL_LOG_DEBUG, LOG_DOMAIN,
"Unknown atom inside [%c%c%c%c] (fourcc: [%c%c%c%c], size: %s)",
(parent & 0xFF000000) >> 24,
(parent & 0x00FF0000) >> 16,
(parent & 0x0000FF00) >> 8,
(parent & 0x000000FF),
(h->fourcc & 0xFF000000) >> 24,
(h->fourcc & 0x00FF0000) >> 16,
(h->fourcc & 0x0000FF00) >> 8,
(h->fourcc & 0x000000FF), tmp_string);
}
bgav_qt_atom_skip(input, h);
}
void bgav_qt_atom_dump_header(int indent, qt_atom_header_t * h)
{
bgav_diprintf(indent, "Size: %" PRId64 "\n", h->size);
bgav_diprintf(indent, "Start Position: %" PRId64 "\n", h->start_position);
bgav_diprintf(indent, "Fourcc: ");
bgav_dump_fourcc(h->fourcc);
bgav_dprintf("\n");
}
|