mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 05:42:19 -04:00
commit
6bc6e22e12
1 changed files with 27 additions and 4 deletions
|
@ -325,8 +325,11 @@ FFmpegVideo::FFmpegVideo()
|
||||||
|
|
||||||
//AVCodecID codec_id = AV_CODEC_ID_H264 ;
|
//AVCodecID codec_id = AV_CODEC_ID_H264 ;
|
||||||
//AVCodecID codec_id = AV_CODEC_ID_MPEG2VIDEO;
|
//AVCodecID codec_id = AV_CODEC_ID_MPEG2VIDEO;
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR < 55
|
||||||
|
CodecID codec_id = CODEC_ID_MPEG4;
|
||||||
|
#else
|
||||||
AVCodecID codec_id = AV_CODEC_ID_MPEG4;
|
AVCodecID codec_id = AV_CODEC_ID_MPEG4;
|
||||||
|
#endif
|
||||||
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
||||||
|
|
||||||
/* find the mpeg1 video encoder */
|
/* find the mpeg1 video encoder */
|
||||||
|
@ -385,10 +388,15 @@ FFmpegVideo::FFmpegVideo()
|
||||||
*/
|
*/
|
||||||
encoding_context->gop_size = 100;
|
encoding_context->gop_size = 100;
|
||||||
//encoding_context->max_b_frames = 1;
|
//encoding_context->max_b_frames = 1;
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR < 55
|
||||||
|
encoding_context->pix_fmt = PIX_FMT_YUV420P; //context->pix_fmt = PIX_FMT_RGB24;
|
||||||
|
if (codec_id == CODEC_ID_H264) {
|
||||||
|
#else
|
||||||
encoding_context->pix_fmt = AV_PIX_FMT_YUV420P; //context->pix_fmt = AV_PIX_FMT_RGB24;
|
encoding_context->pix_fmt = AV_PIX_FMT_YUV420P; //context->pix_fmt = AV_PIX_FMT_RGB24;
|
||||||
|
if (codec_id == AV_CODEC_ID_H264) {
|
||||||
if (codec_id == AV_CODEC_ID_H264)
|
#endif
|
||||||
av_opt_set(encoding_context->priv_data, "preset", "slow", 0);
|
av_opt_set(encoding_context->priv_data, "preset", "slow", 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* open it */
|
/* open it */
|
||||||
if (avcodec_open2(encoding_context, encoding_codec, NULL) < 0)
|
if (avcodec_open2(encoding_context, encoding_codec, NULL) < 0)
|
||||||
|
@ -428,7 +436,11 @@ FFmpegVideo::FFmpegVideo()
|
||||||
|
|
||||||
decoding_context->width = encoding_context->width;
|
decoding_context->width = encoding_context->width;
|
||||||
decoding_context->height = encoding_context->height;
|
decoding_context->height = encoding_context->height;
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR < 55
|
||||||
|
decoding_context->pix_fmt = PIX_FMT_YUV420P;
|
||||||
|
#else
|
||||||
decoding_context->pix_fmt = AV_PIX_FMT_YUV420P;
|
decoding_context->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(decoding_codec->capabilities & CODEC_CAP_TRUNCATED)
|
if(decoding_codec->capabilities & CODEC_CAP_TRUNCATED)
|
||||||
decoding_context->flags |= CODEC_FLAG_TRUNCATED; // we do not send complete frames
|
decoding_context->flags |= CODEC_FLAG_TRUNCATED; // we do not send complete frames
|
||||||
|
@ -536,12 +548,24 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra
|
||||||
|
|
||||||
AVPacket pkt ;
|
AVPacket pkt ;
|
||||||
av_init_packet(&pkt);
|
av_init_packet(&pkt);
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR < 55
|
||||||
|
pkt.size = avpicture_get_size(encoding_context->pix_fmt, encoding_context->width, encoding_context->height);
|
||||||
|
pkt.data = (uint8_t*)av_malloc(pkt.size);
|
||||||
|
|
||||||
|
// do
|
||||||
|
// {
|
||||||
|
int ret = avcodec_encode_video(encoding_context, pkt.data, pkt.size, frame) ;
|
||||||
|
if (ret > 0) {
|
||||||
|
got_output = ret;
|
||||||
|
}
|
||||||
|
#else
|
||||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||||
pkt.size = 0;
|
pkt.size = 0;
|
||||||
|
|
||||||
// do
|
// do
|
||||||
// {
|
// {
|
||||||
int ret = avcodec_encode_video2(encoding_context, &pkt, frame, &got_output) ;
|
int ret = avcodec_encode_video2(encoding_context, &pkt, frame, &got_output) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
@ -682,4 +706,3 @@ bool FFmpegVideo::decodeData(const RsVOIPDataChunk& chunk,QImage& image)
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue