diff options
Diffstat (limited to 'src/demuxers')
-rw-r--r-- | src/demuxers/Makefile.am | 9 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 22 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_pes.c | 22 | ||||
-rw-r--r-- | src/demuxers/demux_ts.c | 38 |
4 files changed, 54 insertions, 37 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am index 276505521..596d7dbd0 100644 --- a/src/demuxers/Makefile.am +++ b/src/demuxers/Makefile.am @@ -57,7 +57,8 @@ xineplug_dmx_avi_la_SOURCES = demux_avi.c xineplug_dmx_avi_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) xineplug_dmx_mpeg_block_la_SOURCES = demux_mpeg_block.c -xineplug_dmx_mpeg_block_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) +xineplug_dmx_mpeg_block_la_CFLAGS = $(AM_CFLAGS) $(AVUTIL_CFLAGS) +xineplug_dmx_mpeg_block_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(AVUTIL_LIBS) xineplug_dmx_mpeg_la_SOURCES = demux_mpeg.c xineplug_dmx_mpeg_la_LIBADD = $(XINE_LIB) @@ -66,10 +67,12 @@ xineplug_dmx_mpeg_elem_la_SOURCES = demux_elem.c xineplug_dmx_mpeg_elem_la_LIBADD = $(XINE_LIB) xineplug_dmx_mpeg_pes_la_SOURCES = demux_mpeg_pes.c -xineplug_dmx_mpeg_pes_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) +xineplug_dmx_mpeg_pes_la_CFLAGS = $(AM_CFLAGS) $(AVUTIL_CFLAGS) +xineplug_dmx_mpeg_pes_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(AVUTIL_LIBS) xineplug_dmx_mpeg_ts_la_SOURCES = demux_ts.c -xineplug_dmx_mpeg_ts_la_LIBADD = $(XINE_LIB) +xineplug_dmx_mpeg_ts_la_CFLAGS = $(AM_CFLAGS) $(AVUTIL_CFLAGS) +xineplug_dmx_mpeg_ts_la_LIBADD = $(XINE_LIB) $(AVUTIL_LIBS) xineplug_dmx_qt_la_SOURCES = demux_qt.c xineplug_dmx_qt_la_LIBADD = $(XINE_LIB) $(ZLIB_LIBS) diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index b46008b94..84bbf1492 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.c @@ -31,6 +31,9 @@ #include <unistd.h> #include <string.h> +/* libavutil from FFmpeg */ +#include <mem.h> + #define LOG_MODULE "demux_mpeg_block" #define LOG_VERBOSE /* @@ -70,7 +73,6 @@ typedef struct demux_mpeg_block_s { char cur_mrl[256]; uint8_t *scratch; - void *scratch_base; int64_t nav_last_end_pts; int64_t nav_last_start_pts; @@ -1176,7 +1178,7 @@ static void demux_mpeg_block_dispose (demux_plugin_t *this_gen) { demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; - free (this->scratch_base); + av_free (this->scratch); free (this); } @@ -1385,7 +1387,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->demux_plugin.get_optional_data = demux_mpeg_block_get_optional_data; this->demux_plugin.demux_class = class_gen; - this->scratch = xine_xmalloc_aligned (512, 4096, &this->scratch_base); + this->scratch = av_mallocz(4096); this->status = DEMUX_FINISHED; lprintf ("open_plugin:detection_method=%d\n", @@ -1397,7 +1399,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str /* use demux_mpeg for non-block devices */ if (!(input->get_capabilities(input) & INPUT_CAP_BLOCK)) { - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1411,7 +1413,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->blocksize = demux_mpeg_detect_blocksize( this, input ); if (!this->blocksize) { - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1424,7 +1426,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str || (this->scratch[2] != 0x01) || (this->scratch[3] != 0xba)) { lprintf("open_plugin:scratch failed\n"); - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1432,7 +1434,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str /* if it's a file then make sure it's mpeg-2 */ if ( !input->get_blocksize(input) && ((this->scratch[4]>>4) != 4) ) { - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1446,7 +1448,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str break; } } - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1463,7 +1465,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->blocksize = demux_mpeg_detect_blocksize( this, input ); if (!this->blocksize) { - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1473,7 +1475,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str break; default: - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index f5d554020..a4f8fced0 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.c @@ -35,6 +35,9 @@ #include <unistd.h> #include <string.h> +/* libavutil from FFmpeg */ +#include <mem.h> + #define LOG_MODULE "demux_mpeg_pes" #define LOG_VERBOSE /* @@ -73,7 +76,6 @@ typedef struct demux_mpeg_pes_s { char cur_mrl[256]; uint8_t *scratch; - void *scratch_base; int64_t nav_last_end_pts; int64_t nav_last_start_pts; @@ -1441,7 +1443,7 @@ static void demux_mpeg_pes_dispose (demux_plugin_t *this_gen) { demux_mpeg_pes_t *this = (demux_mpeg_pes_t *) this_gen; - free (this->scratch_base); + av_free (this->scratch); free (this); } @@ -1627,7 +1629,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->demux_plugin.get_optional_data = demux_mpeg_pes_get_optional_data; this->demux_plugin.demux_class = class_gen; - this->scratch = xine_xmalloc_aligned (512, 4096, &this->scratch_base); + this->scratch = av_mallocz(4096); this->status = DEMUX_FINISHED; /* Don't start demuxing stream until we see a program_stream_pack_header */ /* We need to system header in order to identify is the stream is mpeg1 or mpeg2. */ @@ -1646,7 +1648,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str /* use demux_mpeg_block for block devices */ if ((input->get_capabilities(input) & INPUT_CAP_BLOCK)) { - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1662,7 +1664,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str || (this->preview_data[2] != 0x01) ) { lprintf("open_plugin:preview_data failed\n"); - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1673,7 +1675,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str case 0xbd ... 0xbe: break; default: - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1695,7 +1697,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str || (this->scratch[2] != 0x01) ) { lprintf("open_plugin:scratch failed\n"); - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1706,7 +1708,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str case 0xbd ... 0xbe: break; default: - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1720,7 +1722,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str } } - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } @@ -1736,7 +1738,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str break; default: - free (this->scratch_base); + av_free (this->scratch); free (this); return NULL; } diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 2f88c8963..5d85a5597 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -141,6 +141,9 @@ #include <unistd.h> #include <string.h> +/* libavutil from FFmpeg */ +#include <crc.h> + #define LOG_MODULE "demux_ts" #define LOG_VERBOSE /* @@ -272,6 +275,18 @@ typedef struct { } demux_ts_audio_track; typedef struct { + + demux_class_t demux_class; + + /* class-wide, global variables here */ + + xine_t *xine; + config_values_t *config; + + const AVCRC *av_crc; +} demux_ts_class_t; + +typedef struct { /* * The first field must be the "base class" for the plugin! */ @@ -286,6 +301,8 @@ typedef struct { input_plugin_t *input; + demux_ts_class_t *class; + int status; int blockSize; @@ -344,17 +361,6 @@ typedef struct { } demux_ts_t; -typedef struct { - - demux_class_t demux_class; - - /* class-wide, global variables here */ - - xine_t *xine; - config_values_t *config; -} demux_ts_class_t; - - /* redefine abs as macro to handle 64-bit diffs. i guess llabs may not be available everywhere */ #define abs(x) ( ((x)<0) ? -(x) : (x) ) @@ -573,7 +579,7 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt, } /* Check CRC. */ - calc_crc32 = _x_compute_crc32 (pkt+5, section_length+3-4, 0xffffffff); + calc_crc32 = av_crc(this->class->av_crc, 0xffffffff, pkt+5, section_length+3-4); if (crc32 != calc_crc32) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: demux error! PAT with invalid CRC32: packet_crc32: %.8x calc_crc32: %.8x\n", @@ -1188,8 +1194,9 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num crc32 |= (uint32_t) this->pmt[program_count][section_length+3-1] ; /* Check CRC. */ - calc_crc32 = _x_compute_crc32 (this->pmt[program_count], - section_length+3-4, 0xffffffff); + calc_crc32 = av_crc(this->class->av_crc, 0xffffffff, + this->pmt[program_count], section_length+3-4); + if (crc32 != calc_crc32) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: demux error! PMT with invalid CRC32: packet_crc32: %#.8x calc_crc32: %#.8x\n", @@ -2186,6 +2193,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this = xine_xmalloc(sizeof(*this)); this->stream = stream; this->input = input; + this->class = class_gen; this->blockSize = PKT_SIZE; this->demux_plugin.send_headers = demux_ts_send_headers; @@ -2264,6 +2272,8 @@ static void *init_class (xine_t *xine, void *data) { this->demux_class.extensions = "ts m2t trp dvb:// dvbs:// dvbc:// dvbt://"; this->demux_class.dispose = default_demux_class_dispose; + this->av_crc = av_crc_get_table(AV_CRC_32_IEEE); + return this; } |