summaryrefslogtreecommitdiff
path: root/libavformat/mpegts.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-03-08 17:28:42 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-03-08 19:12:03 +0100
commit2653e125204569b1e9439ee2671c6ebb23a94b80 (patch)
tree4176f76bccc8cdd1c85b9d329a82867eda37d397 /libavformat/mpegts.c
parent532f31a695c9530ce67a847be00d72e6e8acfd11 (diff)
parent1afddbe59e96af75f1c07605afc95615569f388f (diff)
Merge commit '1afddbe59e96af75f1c07605afc95615569f388f'
* commit '1afddbe59e96af75f1c07605afc95615569f388f': avpacket: use AVBuffer to allow refcounting the packets. Conflicts: libavcodec/avpacket.c libavcodec/utils.c libavdevice/v4l2.c libavformat/avidec.c libavformat/flacdec.c libavformat/id3v2.c libavformat/matroskaenc.c libavformat/mux.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mpegts.c')
-rw-r--r--libavformat/mpegts.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8b92bc421e..d639623f8b 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/buffer.h"
#include "libavutil/crc.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
@@ -176,7 +177,7 @@ typedef struct PESContext {
int64_t pts, dts;
int64_t ts_packet_pos; /**< position of first TS packet of this PES packet */
uint8_t header[MAX_PES_HEADER_SIZE];
- uint8_t *buffer;
+ AVBufferRef *buffer;
SLConfigDescr sl;
} PESContext;
@@ -406,7 +407,7 @@ static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
av_freep(&filter->u.section_filter.section_buf);
else if (filter->type == MPEGTS_PES) {
PESContext *pes = filter->u.pes_filter.opaque;
- av_freep(&pes->buffer);
+ av_buffer_unref(&pes->buffer);
/* referenced private data will be freed later in
* avformat_close_input */
if (!((PESContext *)filter->u.pes_filter.opaque)->st) {
@@ -703,8 +704,8 @@ static void new_pes_packet(PESContext *pes, AVPacket *pkt)
{
av_init_packet(pkt);
- pkt->destruct = av_destruct_packet;
- pkt->data = pes->buffer;
+ pkt->buf = pes->buffer;
+ pkt->data = pes->buffer->data;
pkt->size = pes->data_index;
if(pes->total_size != MAX_PES_PAYLOAD &&
@@ -869,7 +870,8 @@ static int mpegts_push_data(MpegTSFilter *filter,
pes->total_size = MAX_PES_PAYLOAD;
/* allocate pes buffer */
- pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
+ pes->buffer = av_buffer_alloc(pes->total_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
if (!pes->buffer)
return AVERROR(ENOMEM);
@@ -971,7 +973,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
if (pes->data_index > 0 && pes->data_index+buf_size > pes->total_size) {
new_pes_packet(pes, ts->pkt);
pes->total_size = MAX_PES_PAYLOAD;
- pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
+ pes->buffer = av_buffer_alloc(pes->total_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!pes->buffer)
return AVERROR(ENOMEM);
ts->stop_parse = 1;
@@ -980,7 +982,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
// not sure if this is legal in ts but see issue #2392
buf_size = pes->total_size;
}
- memcpy(pes->buffer+pes->data_index, p, buf_size);
+ memcpy(pes->buffer->data + pes->data_index, p, buf_size);
pes->data_index += buf_size;
}
buf_size = 0;
@@ -1880,7 +1882,7 @@ static int handle_packets(MpegTSContext *ts, int nb_packets)
if (ts->pids[i]) {
if (ts->pids[i]->type == MPEGTS_PES) {
PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
- av_freep(&pes->buffer);
+ av_buffer_unref(&pes->buffer);
pes->data_index = 0;
pes->state = MPEGTS_SKIP; /* skip until pes header */
}