~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to libmpdemux/demux_ogg.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#endif
50
50
 
51
51
#ifdef CONFIG_OGGTHEORA
52
 
#include <theora/theora.h>
53
 
int _ilog (unsigned int); /* defined in many places in theora/lib/ */
 
52
#include <theora/theoradec.h>
54
53
#endif
55
54
 
56
55
#define BLOCK_SIZE 4096
57
56
 
58
57
/* Theora decoder context : we won't be able to interpret granule positions
59
 
 * without using theora_granule_time with the theora_state of the stream.
 
58
 * without using th_granule_time with the th_dec_ctx of the stream.
60
59
 * This is duplicated in `vd_theora.c'; put this in a common header?
61
60
 */
62
61
#ifdef CONFIG_OGGTHEORA
63
62
typedef struct theora_struct_st {
64
 
    theora_state   st;
65
 
    theora_comment cc;
66
 
    theora_info    inf;
 
63
    th_setup_info *tsi;
 
64
    th_dec_ctx    *tctx;
 
65
    th_comment     tc;
 
66
    th_info        ti;
67
67
} theora_struct_t;
68
68
#endif
69
69
 
116
116
    float   samplerate; /// granulpos 2 time
117
117
    int64_t lastpos;
118
118
    int32_t lastsize;
119
 
    int     keyframe_frequency_force;
 
119
    int     keyframe_granule_shift;
120
120
 
121
121
    // Logical stream state
122
122
    ogg_stream_state stream;
202
202
            duration  |= (unsigned char)packet[i];
203
203
        }
204
204
        if (hdrlen > 0 && duration > 0) {
205
 
            float pts;
 
205
            double pts;
206
206
 
207
207
            if (pack->granulepos == -1)
208
208
                pack->granulepos = os->lastpos + os->lastsize;
209
 
            pts    = (float)pack->granulepos / (float)os->samplerate;
210
 
            endpts = 1.0 + pts + (float)duration / 1000.0;
 
209
            pts    = (double)pack->granulepos / (double)os->samplerate;
 
210
            endpts = 1.0 + pts + (double)duration / 1000.0;
211
211
        }
212
212
        sub_clear_text(&ogg_sub, MP_NOPTS_VALUE);
213
213
        sub_add_text(&ogg_sub, &packet[lcv], pack->bytes - lcv, endpts, 1);
257
257
}
258
258
 
259
259
static unsigned char *demux_ogg_read_packet(ogg_stream_t *os, ogg_packet *pack,
260
 
                                            float *pts, int *flags,
 
260
                                            double *pts, int *flags,
261
261
                                            int samplesize)
262
262
{
263
263
    unsigned char *data = pack->packet;
284
284
            } else
285
285
                *flags = 1;
286
286
            if (vi)
287
 
                *pts = pack->granulepos / (float)vi->rate;
 
287
                *pts = pack->granulepos / (double)vi->rate;
288
288
            os->lastsize = blocksize;
289
289
            os->lastpos  = pack->granulepos;
290
290
        }
299
299
           have theora_state st, until all header packets were passed to the
300
300
           decoder. */
301
301
        if (!pack->bytes || !(*data&0x80)) {
302
 
            int keyframe_granule_shift = _ilog(os->keyframe_frequency_force - 1);
303
 
            int64_t iframemask = (1 << keyframe_granule_shift) - 1;
 
302
            int64_t iframemask = (1 << os->keyframe_granule_shift) - 1;
304
303
 
305
304
            if (pack->granulepos >= 0) {
306
 
                os->lastpos  = pack->granulepos >> keyframe_granule_shift;
 
305
                os->lastpos  = pack->granulepos >> os->keyframe_granule_shift;
307
306
                os->lastpos += pack->granulepos & iframemask;
308
307
                *flags = (pack->granulepos & iframemask) == 0;
309
308
            } else {
480
479
    demuxer_t *d = ds->demuxer;
481
480
    demux_packet_t *dp;
482
481
    unsigned char *data;
483
 
    float pts = 0;
 
482
    double pts = 0;
484
483
    int flags = 0;
485
484
    int samplesize = 1;
486
485
 
609
608
        }
610
609
        p = 0;
611
610
        while (ogg_stream_packetout(oss, &op) == 1) {
612
 
            float pts;
 
611
            double pts;
613
612
            int flags;
614
613
 
615
614
            demux_ogg_read_packet(os, &op, &pts, &flags, samplesize);
892
891
#ifdef CONFIG_OGGTHEORA
893
892
        } else if (pack.bytes >= 7 && !strncmp (&pack.packet[1], "theora", 6)) {
894
893
            int errorCode = 0;
895
 
            theora_info inf;
896
 
            theora_comment cc;
897
 
 
898
 
            theora_info_init (&inf);
899
 
            theora_comment_init (&cc);
900
 
 
901
 
            errorCode = theora_decode_header (&inf, &cc, &pack);
902
 
            if (errorCode) {
 
894
            th_info ti;
 
895
            th_comment tc;
 
896
            th_setup_info *tsi = NULL;
 
897
 
 
898
            th_info_init (&ti);
 
899
            th_comment_init (&tc);
 
900
 
 
901
            errorCode = th_decode_headerin(&ti, &tc, &tsi, &pack);
 
902
            if (errorCode < 0) {
903
903
                mp_msg(MSGT_DEMUX, MSGL_ERR,
904
904
                       "Theora header parsing failed: %i \n", errorCode);
905
905
            } else {
908
908
                sh_v->bih = calloc(1, sizeof(*sh_v->bih));
909
909
                sh_v->bih->biSize        = sizeof(*sh_v->bih);
910
910
                sh_v->bih->biCompression = sh_v->format = FOURCC_THEORA;
911
 
                sh_v->fps = ((double)inf.fps_numerator) / (double)inf.fps_denominator;
912
 
                sh_v->frametime = ((double)inf.fps_denominator) / (double)inf.fps_numerator;
913
 
                sh_v->disp_w = sh_v->bih->biWidth  = inf.frame_width;
914
 
                sh_v->disp_h = sh_v->bih->biHeight = inf.frame_height;
 
911
                sh_v->fps = ((double)ti.fps_numerator) / (double)ti.fps_denominator;
 
912
                sh_v->frametime = ((double)ti.fps_denominator) / (double)ti.fps_numerator;
 
913
                sh_v->i_bps  = ti.target_bitrate / 8;
 
914
                sh_v->disp_w = sh_v->bih->biWidth  = ti.frame_width;
 
915
                sh_v->disp_h = sh_v->bih->biHeight = ti.frame_height;
915
916
                sh_v->bih->biBitCount  = 24;
916
917
                sh_v->bih->biPlanes    = 3;
917
918
                sh_v->bih->biSizeImage = ((sh_v->bih->biBitCount / 8) * sh_v->bih->biWidth * sh_v->bih->biHeight);
918
919
                ogg_d->subs[ogg_d->num_sub].samplerate               = sh_v->fps;
919
920
                ogg_d->subs[ogg_d->num_sub].theora                   = 1;
920
 
                ogg_d->subs[ogg_d->num_sub].keyframe_frequency_force = inf.keyframe_frequency_force;
 
921
                ogg_d->subs[ogg_d->num_sub].keyframe_granule_shift   = ti.keyframe_granule_shift;
921
922
                ogg_d->subs[ogg_d->num_sub].id                       = n_video;
922
923
                n_video++;
923
924
                mp_msg(MSGT_DEMUX, MSGL_INFO,
924
925
                       "[Ogg] stream %d: video (Theora v%d.%d.%d), -vid %d\n",
925
926
                       ogg_d->num_sub,
926
 
                       (int)inf.version_major,
927
 
                       (int)inf.version_minor,
928
 
                       (int)inf.version_subminor,
 
927
                       (int)ti.version_major,
 
928
                       (int)ti.version_minor,
 
929
                       (int)ti.version_subminor,
929
930
                       n_video - 1);
930
931
                if (mp_msg_test(MSGT_HEADER, MSGL_V))
931
932
                    print_video_header(sh_v->bih, MSGL_V);
932
933
            }
933
 
            theora_comment_clear(&cc);
934
 
            theora_info_clear(&inf);
 
934
            th_comment_clear(&tc);
 
935
            th_info_clear(&ti);
 
936
            th_setup_free(tsi);
935
937
#endif /* CONFIG_OGGTHEORA */
936
938
        } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) {
937
939
            sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio, NULL);
1410
1412
    ogg_stream_t *os;
1411
1413
    demux_stream_t *ds;
1412
1414
    ogg_packet op;
1413
 
    float rate;
 
1415
    double rate;
1414
1416
    int i, sp, first, precision = 1, do_seek = 1;
1415
1417
    vorbis_info *vi = NULL;
1416
1418
    int64_t gp = 0, old_gp;
1417
1419
    off_t pos, old_pos;
1418
1420
    int np;
1419
1421
    int is_gp_valid;
1420
 
    float pts;
 
1422
    double pts;
1421
1423
    int is_keyframe;
1422
1424
    int samplesize = 1;
1423
1425
    ogg_int64_t granulepos_orig;
1429
1431
        ds         = demuxer->audio;
1430
1432
        os         = &ogg_d->subs[ds->id];
1431
1433
        vi         = &(os->vi);
1432
 
        rate       = (float)vi->rate;
 
1434
        rate       = vi->rate;
1433
1435
        samplesize = ((sh_audio_t*)ds->sh)->samplesize;
1434
1436
    }
1435
1437
 
1618
1620
{
1619
1621
    ogg_demuxer_t *ogg_d = demuxer->priv;
1620
1622
    ogg_stream_t *os;
1621
 
    float rate;
 
1623
    double rate;
1622
1624
 
1623
1625
    if (demuxer->video->id >= 0) {
1624
1626
        os = &ogg_d->subs[demuxer->video->id];