Skip to content

Commit

Permalink
fix old ffmpeg build and ubuntu 14.4 build
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jun 30, 2016
1 parent 2d0dd1d commit a6d55cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
33 changes: 19 additions & 14 deletions src/AVCompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#include "QtAV/private/AVCompat.h"
#include "QtAV/version.h"

#ifndef av_err2str

#endif //av_err2str

#if !FFMPEG_MODULE_CHECK(LIBAVFORMAT, 56, 4, 101)
int avio_feof(AVIOContext *s)
{
Expand Down Expand Up @@ -328,37 +324,37 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
#else // libav <=11 has no av_copy_packet
#define DUP_DATA(dst, src, size, padding) \
do { \
uint8_t *data; \
void *data; \
if (padding) { \
if ((unsigned)(size) > \
(unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \
goto failed_alloc; \
data = (uint8_t*)av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); \
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); \
} else { \
data = (uint8_t*)av_malloc(size); \
data = av_malloc(size); \
} \
if (!data) \
goto failed_alloc; \
memcpy(data, src, size); \
if (padding) \
memset(data + size, 0, \
memset((uint8_t*)data + size, 0, \
FF_INPUT_BUFFER_PADDING_SIZE); \
dst = data; \
} while (0)

*dst = *src;
dst->data = NULL;
dst->side_data = NULL;
DUP_DATA(dst->data, src->data, dst->size, 1);
DUP_DATA((void*)dst->data, src->data, dst->size, 1);
dst->destruct = av_destruct_packet;
if (dst->side_data_elems) {
int i;
DUP_DATA(dst->side_data, src->side_data,
DUP_DATA((void*)dst->side_data, src->side_data,
dst->side_data_elems * sizeof(*dst->side_data), 0);
memset(dst->side_data, 0,
dst->side_data_elems * sizeof(*dst->side_data));
for (i = 0; i < dst->side_data_elems; i++) {
DUP_DATA(dst->side_data[i].data, src->side_data[i].data, src->side_data[i].size, 1);
DUP_DATA((void*)dst->side_data[i].data, src->side_data[i].data, src->side_data[i].size, 1);
dst->side_data[i].size = src->side_data[i].size;
dst->side_data[i].type = src->side_data[i].type;
}
Expand All @@ -371,10 +367,19 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
}
#endif
#if !AV_MODULE_CHECK(LIBAVCODEC, 55, 52, 0, 63, 100)
void avcodec_free_context(AVCodecContext **avctx)
void avcodec_free_context(AVCodecContext **pavctx)
{
av_freep(avctx->extradata);
av_freep(avctx);

AVCodecContext *avctx = *pavctx;
if (!avctx)
return;
avcodec_close(avctx);
av_freep(&avctx->extradata);
av_freep(&avctx->subtitle_header);
av_freep(&avctx->intra_matrix);
av_freep(&avctx->inter_matrix);
av_freep(&avctx->rc_override);
av_freep(pavctx);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/QtAV/private/AVCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src);
#endif

#if !AV_MODULE_CHECK(LIBAVCODEC, 55, 52, 0, 63, 100)
void avcodec_free_context(AVCodecContext **avctx);
void avcodec_free_context(AVCodecContext **pavctx);
#endif

#if QTAV_HAVE(AVFILTER)
Expand Down

0 comments on commit a6d55cd

Please sign in to comment.