Merge pull request #1321 from SteveGilvarry/ffmpeg3_deprecation
FFMPEG 3.0 deprecation fixespull/1459/head
commit
5321fe35bd
|
@ -160,12 +160,20 @@ int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check the buffer sizes */
|
/* Check the buffer sizes */
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
size_t insize = av_image_get_buffer_size(in_pf, width, height,1);
|
||||||
|
#else
|
||||||
size_t insize = avpicture_get_size(in_pf, width, height);
|
size_t insize = avpicture_get_size(in_pf, width, height);
|
||||||
|
#endif
|
||||||
if(insize != in_buffer_size) {
|
if(insize != in_buffer_size) {
|
||||||
Error("The input buffer size does not match the expected size for the input format. Required: %d Available: %d", insize, in_buffer_size);
|
Error("The input buffer size does not match the expected size for the input format. Required: %d Available: %d", insize, in_buffer_size);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
size_t outsize = av_image_get_buffer_size(out_pf, width, height,1);
|
||||||
|
#else
|
||||||
size_t outsize = avpicture_get_size(out_pf, width, height);
|
size_t outsize = avpicture_get_size(out_pf, width, height);
|
||||||
|
#endif
|
||||||
if(outsize < out_buffer_size) {
|
if(outsize < out_buffer_size) {
|
||||||
Error("The output buffer is undersized for the output format. Required: %d Available: %d", outsize, out_buffer_size);
|
Error("The output buffer is undersized for the output format. Required: %d Available: %d", outsize, out_buffer_size);
|
||||||
return -5;
|
return -5;
|
||||||
|
|
|
@ -47,6 +47,10 @@ extern "C" {
|
||||||
#else
|
#else
|
||||||
#include <libavcodec/opt.h>
|
#include <libavcodec/opt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
|
#endif
|
||||||
#elif HAVE_FFMPEG_AVUTIL_H
|
#elif HAVE_FFMPEG_AVUTIL_H
|
||||||
#include <ffmpeg/avutil.h>
|
#include <ffmpeg/avutil.h>
|
||||||
#include <ffmpeg/base64.h>
|
#include <ffmpeg/base64.h>
|
||||||
|
|
|
@ -182,8 +182,13 @@ int FfmpegCamera::Capture( Image &image )
|
||||||
if ( frameComplete )
|
if ( frameComplete )
|
||||||
{
|
{
|
||||||
Debug( 3, "Got frame %d", frameCount );
|
Debug( 3, "Got frame %d", frameCount );
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
av_image_fill_arrays(mFrame->data, mFrame->linesize,
|
||||||
|
directbuffer, imagePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)mFrame, directbuffer,
|
||||||
|
imagePixFormat, width, height);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_LIBSWSCALE
|
#if HAVE_LIBSWSCALE
|
||||||
if(mConvertContext == NULL) {
|
if(mConvertContext == NULL) {
|
||||||
|
@ -354,7 +359,12 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
|
|
||||||
Debug ( 1, "Allocated frames" );
|
Debug ( 1, "Allocated frames" );
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int pSize = av_image_get_buffer_size( imagePixFormat, width, height,1 );
|
||||||
|
#else
|
||||||
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( (unsigned int)pSize != imagesize) {
|
if( (unsigned int)pSize != imagesize) {
|
||||||
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,7 +626,11 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel,
|
||||||
if ( !tmpPicture )
|
if ( !tmpPicture )
|
||||||
Fatal( "Could not allocate temporary picture" );
|
Fatal( "Could not allocate temporary picture" );
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int pSize = av_image_get_buffer_size( imagePixFormat, width, height,1 );
|
||||||
|
#else
|
||||||
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
||||||
|
#endif
|
||||||
if( (unsigned int)pSize != imagesize) {
|
if( (unsigned int)pSize != imagesize) {
|
||||||
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||||
}
|
}
|
||||||
|
@ -859,7 +863,18 @@ void LocalCamera::Initialise()
|
||||||
#endif
|
#endif
|
||||||
if ( !capturePictures[i] )
|
if ( !capturePictures[i] )
|
||||||
Fatal( "Could not allocate picture" );
|
Fatal( "Could not allocate picture" );
|
||||||
avpicture_fill( (AVPicture *)capturePictures[i], (uint8_t*)v4l2_data.buffers[i].start, capturePixFormat, v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(capturePictures[i]->data,
|
||||||
|
capturePictures[i]->linesize,
|
||||||
|
(uint8_t*)v4l2_data.buffers[i].start,capturePixFormat,
|
||||||
|
v4l2_data.fmt.fmt.pix.width,
|
||||||
|
v4l2_data.fmt.fmt.pix.height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)capturePictures[i],
|
||||||
|
(uint8_t*)v4l2_data.buffers[i].start, capturePixFormat,
|
||||||
|
v4l2_data.fmt.fmt.pix.width,
|
||||||
|
v4l2_data.fmt.fmt.pix.height );
|
||||||
|
#endif
|
||||||
#endif // HAVE_LIBSWSCALE
|
#endif // HAVE_LIBSWSCALE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,7 +1032,16 @@ void LocalCamera::Initialise()
|
||||||
#endif
|
#endif
|
||||||
if ( !capturePictures[i] )
|
if ( !capturePictures[i] )
|
||||||
Fatal( "Could not allocate picture" );
|
Fatal( "Could not allocate picture" );
|
||||||
avpicture_fill( (AVPicture *)capturePictures[i], (unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i], capturePixFormat, width, height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(capturePictures[i]->data,
|
||||||
|
capturePictures[i]->linesize,
|
||||||
|
(unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i],
|
||||||
|
capturePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)capturePictures[i],
|
||||||
|
(unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i],
|
||||||
|
capturePixFormat, width, height );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // HAVE_LIBSWSCALE
|
#endif // HAVE_LIBSWSCALE
|
||||||
|
|
||||||
|
@ -2113,7 +2137,14 @@ int LocalCamera::Capture( Image &image )
|
||||||
|
|
||||||
Debug( 9, "Calling sws_scale to perform the conversion" );
|
Debug( 9, "Calling sws_scale to perform the conversion" );
|
||||||
/* Use swscale to convert the image directly into the shared memory */
|
/* Use swscale to convert the image directly into the shared memory */
|
||||||
avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(tmpPicture->data,
|
||||||
|
tmpPicture->linesize, directbuffer,
|
||||||
|
imagePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)tmpPicture, directbuffer,
|
||||||
|
imagePixFormat, width, height );
|
||||||
|
#endif
|
||||||
sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize );
|
sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -333,7 +333,13 @@ void VideoStream::OpenStream( )
|
||||||
Panic( "Could not allocate opicture" );
|
Panic( "Could not allocate opicture" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int size = av_image_get_buffer_size( c->pix_fmt, c->width,
|
||||||
|
c->height, 1 );
|
||||||
|
#else
|
||||||
int size = avpicture_get_size( c->pix_fmt, c->width, c->height );
|
int size = avpicture_get_size( c->pix_fmt, c->width, c->height );
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t *opicture_buf = (uint8_t *)av_malloc( size );
|
uint8_t *opicture_buf = (uint8_t *)av_malloc( size );
|
||||||
if ( !opicture_buf )
|
if ( !opicture_buf )
|
||||||
{
|
{
|
||||||
|
@ -344,7 +350,13 @@ void VideoStream::OpenStream( )
|
||||||
#endif
|
#endif
|
||||||
Panic( "Could not allocate opicture_buf" );
|
Panic( "Could not allocate opicture_buf" );
|
||||||
}
|
}
|
||||||
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt, c->width, c->height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(opicture->data, opicture->linesize,
|
||||||
|
opicture_buf, c->pix_fmt, c->width, c->height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt,
|
||||||
|
c->width, c->height );
|
||||||
|
#endif
|
||||||
|
|
||||||
/* if the output format is not identical to the input format, then a temporary
|
/* if the output format is not identical to the input format, then a temporary
|
||||||
picture is needed too. It is then converted to the required
|
picture is needed too. It is then converted to the required
|
||||||
|
@ -361,7 +373,12 @@ void VideoStream::OpenStream( )
|
||||||
{
|
{
|
||||||
Panic( "Could not allocate tmp_opicture" );
|
Panic( "Could not allocate tmp_opicture" );
|
||||||
}
|
}
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int size = av_image_get_buffer_size( pf, c->width,
|
||||||
|
c->height,1 );
|
||||||
|
#else
|
||||||
int size = avpicture_get_size( pf, c->width, c->height );
|
int size = avpicture_get_size( pf, c->width, c->height );
|
||||||
|
#endif
|
||||||
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
|
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
|
||||||
if ( !tmp_opicture_buf )
|
if ( !tmp_opicture_buf )
|
||||||
{
|
{
|
||||||
|
@ -372,7 +389,14 @@ void VideoStream::OpenStream( )
|
||||||
#endif
|
#endif
|
||||||
Panic( "Could not allocate tmp_opicture_buf" );
|
Panic( "Could not allocate tmp_opicture_buf" );
|
||||||
}
|
}
|
||||||
avpicture_fill( (AVPicture *)tmp_opicture, tmp_opicture_buf, pf, c->width, c->height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(tmp_opicture->data,
|
||||||
|
tmp_opicture->linesize, tmp_opicture_buf, pf,
|
||||||
|
c->width, c->height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)tmp_opicture,
|
||||||
|
tmp_opicture_buf, pf, c->width, c->height );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,14 +702,14 @@ double VideoStream::ActuallyEncodeFrame( const uint8_t *buffer, int buffer_size,
|
||||||
#endif
|
#endif
|
||||||
if ( got_packet )
|
if ( got_packet )
|
||||||
{
|
{
|
||||||
if ( c->coded_frame->key_frame )
|
// if ( c->coded_frame->key_frame )
|
||||||
{
|
// {
|
||||||
#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
|
//#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
// pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
#else
|
//#else
|
||||||
pkt->flags |= PKT_FLAG_KEY;
|
// pkt->flags |= PKT_FLAG_KEY;
|
||||||
#endif
|
//#endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ( pkt->pts != (int64_t)AV_NOPTS_VALUE )
|
if ( pkt->pts != (int64_t)AV_NOPTS_VALUE )
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,7 +214,12 @@ int RemoteCameraRtsp::PrimeCapture()
|
||||||
if(mRawFrame == NULL || mFrame == NULL)
|
if(mRawFrame == NULL || mFrame == NULL)
|
||||||
Fatal( "Unable to allocate frame(s)");
|
Fatal( "Unable to allocate frame(s)");
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int pSize = av_image_get_buffer_size( imagePixFormat, width, height, 1 );
|
||||||
|
#else
|
||||||
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( (unsigned int)pSize != imagesize) {
|
if( (unsigned int)pSize != imagesize) {
|
||||||
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +335,13 @@ int RemoteCameraRtsp::Capture( Image &image )
|
||||||
|
|
||||||
Debug( 3, "Got frame %d", frameCount );
|
Debug( 3, "Got frame %d", frameCount );
|
||||||
|
|
||||||
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(mFrame->data, mFrame->linesize,
|
||||||
|
directbuffer, imagePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)mFrame, directbuffer,
|
||||||
|
imagePixFormat, width, height);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_LIBSWSCALE
|
#if HAVE_LIBSWSCALE
|
||||||
if(mConvertContext == NULL) {
|
if(mConvertContext == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue