View | Details | Raw Unified | Return to bug 198901 | Differences between
and this patch

Collapse All | Expand All

(-)libmpdemux/demux_ogg.c (-26 / +28 lines)
Lines 50-70 Link Here
50
#endif
50
#endif
51
51
52
#ifdef CONFIG_OGGTHEORA
52
#ifdef CONFIG_OGGTHEORA
53
#include <theora/theora.h>
53
#include <theora/theoradec.h>
54
int _ilog (unsigned int); /* defined in many places in theora/lib/ */
55
#endif
54
#endif
56
55
57
#define BLOCK_SIZE 4096
56
#define BLOCK_SIZE 4096
58
57
59
/* Theora decoder context : we won't be able to interpret granule positions
58
/* Theora decoder context : we won't be able to interpret granule positions
60
 * without using theora_granule_time with the theora_state of the stream.
59
 * without using th_granule_time with the th_dec_ctx of the stream.
61
 * This is duplicated in `vd_theora.c'; put this in a common header?
60
 * This is duplicated in `vd_theora.c'; put this in a common header?
62
 */
61
 */
63
#ifdef CONFIG_OGGTHEORA
62
#ifdef CONFIG_OGGTHEORA
64
typedef struct theora_struct_st {
63
typedef struct theora_struct_st {
65
    theora_state   st;
64
    th_setup_info *tsi;
66
    theora_comment cc;
65
    th_dec_ctx    *tctx;
67
    theora_info    inf;
66
    th_comment     tc;
67
    th_info        ti;		
68
} theora_struct_t;
68
} theora_struct_t;
69
#endif
69
#endif
70
70
Lines 117-123 Link Here
117
    float   samplerate; /// granulpos 2 time
117
    float   samplerate; /// granulpos 2 time
118
    int64_t lastpos;
118
    int64_t lastpos;
119
    int32_t lastsize;
119
    int32_t lastsize;
120
    int     keyframe_frequency_force;
120
    int     keyframe_granule_shift;
121
121
122
    // Logical stream state
122
    // Logical stream state
123
    ogg_stream_state stream;
123
    ogg_stream_state stream;
Lines 300-310 Link Here
300
           have theora_state st, until all header packets were passed to the
300
           have theora_state st, until all header packets were passed to the
301
           decoder. */
301
           decoder. */
302
        if (!pack->bytes || !(*data&0x80)) {
302
        if (!pack->bytes || !(*data&0x80)) {
303
            int keyframe_granule_shift = _ilog(os->keyframe_frequency_force - 1);
303
            int64_t iframemask = (1 << os->keyframe_granule_shift) - 1;
304
            int64_t iframemask = (1 << keyframe_granule_shift) - 1;
305
304
306
            if (pack->granulepos >= 0) {
305
            if (pack->granulepos >= 0) {
307
                os->lastpos  = pack->granulepos >> keyframe_granule_shift;
306
                os->lastpos  = pack->granulepos >> os->keyframe_granule_shift;
308
                os->lastpos += pack->granulepos & iframemask;
307
                os->lastpos += pack->granulepos & iframemask;
309
                *keyframe = (pack->granulepos & iframemask) == 0;
308
                *keyframe = (pack->granulepos & iframemask) == 0;
310
            } else {
309
            } else {
Lines 888-901 Link Here
888
#ifdef CONFIG_OGGTHEORA
887
#ifdef CONFIG_OGGTHEORA
889
        } else if (pack.bytes >= 7 && !strncmp (&pack.packet[1], "theora", 6)) {
888
        } else if (pack.bytes >= 7 && !strncmp (&pack.packet[1], "theora", 6)) {
890
            int errorCode = 0;
889
            int errorCode = 0;
891
            theora_info inf;
890
            th_info ti;
892
            theora_comment cc;
891
            th_comment tc;
892
	    th_setup_info *tsi = NULL;	
893
893
894
            theora_info_init (&inf);
894
            th_info_init (&ti);
895
            theora_comment_init (&cc);
895
            th_comment_init (&tc);
896
896
897
            errorCode = theora_decode_header (&inf, &cc, &pack);
897
            errorCode = th_decode_headerin (&ti, &tc, &tsi, &pack);
898
            if (errorCode) {
898
            if (errorCode < 0) {
899
                mp_msg(MSGT_DEMUX, MSGL_ERR,
899
                mp_msg(MSGT_DEMUX, MSGL_ERR,
900
                       "Theora header parsing failed: %i \n", errorCode);
900
                       "Theora header parsing failed: %i \n", errorCode);
901
            } else {
901
            } else {
Lines 904-933 Link Here
904
                sh_v->bih = calloc(1, sizeof(*sh_v->bih));
904
                sh_v->bih = calloc(1, sizeof(*sh_v->bih));
905
                sh_v->bih->biSize        = sizeof(*sh_v->bih);
905
                sh_v->bih->biSize        = sizeof(*sh_v->bih);
906
                sh_v->bih->biCompression = sh_v->format = FOURCC_THEORA;
906
                sh_v->bih->biCompression = sh_v->format = FOURCC_THEORA;
907
                sh_v->fps = ((double)inf.fps_numerator) / (double)inf.fps_denominator;
907
                sh_v->fps = ((double)ti.fps_numerator) / (double)ti.fps_denominator;
908
                sh_v->frametime = ((double)inf.fps_denominator) / (double)inf.fps_numerator;
908
                sh_v->frametime = ((double)ti.fps_denominator) / (double)ti.fps_numerator;
909
                sh_v->disp_w = sh_v->bih->biWidth  = inf.frame_width;
909
                sh_v->i_bps = ti.target_bitrate / 8;
910
                sh_v->disp_h = sh_v->bih->biHeight = inf.frame_height;
910
                sh_v->disp_w = sh_v->bih->biWidth  = ti.frame_width;
911
                sh_v->disp_h = sh_v->bih->biHeight = ti.frame_height;
911
                sh_v->bih->biBitCount  = 24;
912
                sh_v->bih->biBitCount  = 24;
912
                sh_v->bih->biPlanes    = 3;
913
                sh_v->bih->biPlanes    = 3;
913
                sh_v->bih->biSizeImage = ((sh_v->bih->biBitCount / 8) * sh_v->bih->biWidth * sh_v->bih->biHeight);
914
                sh_v->bih->biSizeImage = ((sh_v->bih->biBitCount / 8) * sh_v->bih->biWidth * sh_v->bih->biHeight);
914
                ogg_d->subs[ogg_d->num_sub].samplerate               = sh_v->fps;
915
                ogg_d->subs[ogg_d->num_sub].samplerate               = sh_v->fps;
915
                ogg_d->subs[ogg_d->num_sub].theora                   = 1;
916
                ogg_d->subs[ogg_d->num_sub].theora                   = 1;
916
                ogg_d->subs[ogg_d->num_sub].keyframe_frequency_force = inf.keyframe_frequency_force;
917
                ogg_d->subs[ogg_d->num_sub].keyframe_granule_shift = ti.keyframe_granule_shift;
917
                ogg_d->subs[ogg_d->num_sub].id                       = n_video;
918
                ogg_d->subs[ogg_d->num_sub].id                       = n_video;
918
                n_video++;
919
                n_video++;
919
                mp_msg(MSGT_DEMUX, MSGL_INFO,
920
                mp_msg(MSGT_DEMUX, MSGL_INFO,
920
                       "[Ogg] stream %d: video (Theora v%d.%d.%d), -vid %d\n",
921
                       "[Ogg] stream %d: video (Theora v%d.%d.%d), -vid %d\n",
921
                       ogg_d->num_sub,
922
                       ogg_d->num_sub,
922
                       (int)inf.version_major,
923
                       (int)ti.version_major,
923
                       (int)inf.version_minor,
924
                       (int)ti.version_minor,
924
                       (int)inf.version_subminor,
925
                       (int)ti.version_subminor,
925
                       n_video - 1);
926
                       n_video - 1);
926
                if (mp_msg_test(MSGT_HEADER, MSGL_V))
927
                if (mp_msg_test(MSGT_HEADER, MSGL_V))
927
                    print_video_header(sh_v->bih, MSGL_V);
928
                    print_video_header(sh_v->bih, MSGL_V);
928
            }
929
            }
929
            theora_comment_clear(&cc);
930
            th_comment_clear(&tc);
930
            theora_info_clear(&inf);
931
            th_info_clear(&ti);
932
            th_setup_free(tsi);
931
#endif /* CONFIG_OGGTHEORA */
933
#endif /* CONFIG_OGGTHEORA */
932
        } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) {
934
        } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) {
933
            sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio);
935
            sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio);

Return to bug 198901