Add a av_grow_packet function, to be used by code that merges
palette and video data packets to get rid of PaletteControl. Originally committed as revision 25776 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@@ -32,7 +32,7 @@
|
|||||||
#include "libavutil/cpu.h"
|
#include "libavutil/cpu.h"
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 52
|
#define LIBAVCODEC_VERSION_MAJOR 52
|
||||||
#define LIBAVCODEC_VERSION_MINOR 96
|
#define LIBAVCODEC_VERSION_MINOR 97
|
||||||
#define LIBAVCODEC_VERSION_MICRO 0
|
#define LIBAVCODEC_VERSION_MICRO 0
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
@@ -3026,6 +3026,14 @@ int av_new_packet(AVPacket *pkt, int size);
|
|||||||
*/
|
*/
|
||||||
void av_shrink_packet(AVPacket *pkt, int size);
|
void av_shrink_packet(AVPacket *pkt, int size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increase packet size, correctly zeroing padding
|
||||||
|
*
|
||||||
|
* @param pkt packet
|
||||||
|
* @param grow_by number of bytes by which to increase the size of the packet
|
||||||
|
*/
|
||||||
|
int av_grow_packet(AVPacket *pkt, int grow_by);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @warning This is a hack - the packet memory allocation stuff is broken. The
|
* @warning This is a hack - the packet memory allocation stuff is broken. The
|
||||||
* packet is allocated if it was not really allocated.
|
* packet is allocated if it was not really allocated.
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "libavutil/avassert.h"
|
||||||
|
|
||||||
|
|
||||||
void av_destruct_packet_nofree(AVPacket *pkt)
|
void av_destruct_packet_nofree(AVPacket *pkt)
|
||||||
@@ -71,6 +72,23 @@ void av_shrink_packet(AVPacket *pkt, int size)
|
|||||||
memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int av_grow_packet(AVPacket *pkt, int grow_by)
|
||||||
|
{
|
||||||
|
void *new_ptr;
|
||||||
|
av_assert0((unsigned)pkt->size <= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
if (!pkt->size)
|
||||||
|
return av_new_packet(pkt, grow_by);
|
||||||
|
if ((unsigned)grow_by > INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE))
|
||||||
|
return -1;
|
||||||
|
new_ptr = av_realloc(pkt->data, pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
if (!new_ptr)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
pkt->data = new_ptr;
|
||||||
|
pkt->size += grow_by;
|
||||||
|
memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int av_dup_packet(AVPacket *pkt)
|
int av_dup_packet(AVPacket *pkt)
|
||||||
{
|
{
|
||||||
if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {
|
if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {
|
||||||
|
Reference in New Issue
Block a user