mirror of https://git.videolan.org/git/ffmpeg.git
avcodec: Remove deprecated AVPacket API
Deprecated in ce70f28a17
.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
df6b44182e
commit
ab227d8fe1
|
@ -174,108 +174,6 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if FF_API_AVPACKET_OLD_API
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
#define ALLOC_MALLOC(data, size) data = av_malloc(size)
|
||||
#define ALLOC_BUF(data, size) \
|
||||
do { \
|
||||
av_buffer_realloc(&pkt->buf, size); \
|
||||
data = pkt->buf ? pkt->buf->data : NULL; \
|
||||
} while (0)
|
||||
|
||||
#define DUP_DATA(dst, src, size, padding, ALLOC) \
|
||||
do { \
|
||||
void *data; \
|
||||
if (padding) { \
|
||||
if ((unsigned)(size) > \
|
||||
(unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \
|
||||
goto failed_alloc; \
|
||||
ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \
|
||||
} else { \
|
||||
ALLOC(data, size); \
|
||||
} \
|
||||
if (!data) \
|
||||
goto failed_alloc; \
|
||||
memcpy(data, src, size); \
|
||||
if (padding) \
|
||||
memset((uint8_t *)data + size, 0, \
|
||||
AV_INPUT_BUFFER_PADDING_SIZE); \
|
||||
dst = data; \
|
||||
} while (0)
|
||||
|
||||
/* Makes duplicates of data, side_data, but does not copy any other fields */
|
||||
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
|
||||
{
|
||||
pkt->data = NULL;
|
||||
pkt->side_data = NULL;
|
||||
pkt->side_data_elems = 0;
|
||||
if (pkt->buf) {
|
||||
AVBufferRef *ref = av_buffer_ref(src->buf);
|
||||
if (!ref)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->buf = ref;
|
||||
pkt->data = ref->data;
|
||||
} else {
|
||||
DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
|
||||
}
|
||||
if (src->side_data_elems && dup) {
|
||||
pkt->side_data = src->side_data;
|
||||
pkt->side_data_elems = src->side_data_elems;
|
||||
}
|
||||
if (src->side_data_elems && !dup) {
|
||||
return av_copy_packet_side_data(pkt, src);
|
||||
}
|
||||
return 0;
|
||||
|
||||
failed_alloc:
|
||||
av_packet_unref(pkt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
|
||||
{
|
||||
if (src->side_data_elems) {
|
||||
int i;
|
||||
DUP_DATA(pkt->side_data, src->side_data,
|
||||
src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
|
||||
if (src != pkt) {
|
||||
memset(pkt->side_data, 0,
|
||||
src->side_data_elems * sizeof(*src->side_data));
|
||||
}
|
||||
for (i = 0; i < src->side_data_elems; i++) {
|
||||
DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
|
||||
src->side_data[i].size, 1, ALLOC_MALLOC);
|
||||
pkt->side_data[i].size = src->side_data[i].size;
|
||||
pkt->side_data[i].type = src->side_data[i].type;
|
||||
}
|
||||
}
|
||||
pkt->side_data_elems = src->side_data_elems;
|
||||
return 0;
|
||||
|
||||
failed_alloc:
|
||||
av_packet_unref(pkt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
int av_dup_packet(AVPacket *pkt)
|
||||
{
|
||||
AVPacket tmp_pkt;
|
||||
|
||||
if (!pkt->buf && pkt->data) {
|
||||
tmp_pkt = *pkt;
|
||||
return copy_packet_data(pkt, &tmp_pkt, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_copy_packet(AVPacket *dst, const AVPacket *src)
|
||||
{
|
||||
*dst = *src;
|
||||
return copy_packet_data(dst, src, 0);
|
||||
}
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
void av_packet_free_side_data(AVPacket *pkt)
|
||||
{
|
||||
int i;
|
||||
|
@ -285,22 +183,6 @@ void av_packet_free_side_data(AVPacket *pkt)
|
|||
pkt->side_data_elems = 0;
|
||||
}
|
||||
|
||||
#if FF_API_AVPACKET_OLD_API
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
void av_free_packet(AVPacket *pkt)
|
||||
{
|
||||
if (pkt) {
|
||||
if (pkt->buf)
|
||||
av_buffer_unref(&pkt->buf);
|
||||
pkt->data = NULL;
|
||||
pkt->size = 0;
|
||||
|
||||
av_packet_free_side_data(pkt);
|
||||
}
|
||||
}
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
uint8_t *data, size_t size)
|
||||
{
|
||||
|
|
|
@ -519,45 +519,6 @@ int av_grow_packet(AVPacket *pkt, int grow_by);
|
|||
*/
|
||||
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
|
||||
|
||||
#if FF_API_AVPACKET_OLD_API
|
||||
/**
|
||||
* @warning This is a hack - the packet memory allocation stuff is broken. The
|
||||
* packet is allocated if it was not really allocated.
|
||||
*
|
||||
* @deprecated Use av_packet_ref or av_packet_make_refcounted
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_dup_packet(AVPacket *pkt);
|
||||
/**
|
||||
* Copy packet, including contents
|
||||
*
|
||||
* @return 0 on success, negative AVERROR on fail
|
||||
*
|
||||
* @deprecated Use av_packet_ref
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_copy_packet(AVPacket *dst, const AVPacket *src);
|
||||
|
||||
/**
|
||||
* Copy packet side data
|
||||
*
|
||||
* @return 0 on success, negative AVERROR on fail
|
||||
*
|
||||
* @deprecated Use av_packet_copy_props
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src);
|
||||
|
||||
/**
|
||||
* Free a packet.
|
||||
*
|
||||
* @deprecated Use av_packet_unref
|
||||
*
|
||||
* @param pkt packet to free
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_free_packet(AVPacket *pkt);
|
||||
#endif
|
||||
/**
|
||||
* Allocate new information of a packet.
|
||||
*
|
||||
|
|
|
@ -60,9 +60,6 @@
|
|||
#ifndef FF_API_AVPICTURE
|
||||
#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_AVPACKET_OLD_API
|
||||
#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_RTP_CALLBACK
|
||||
#define FF_API_RTP_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue