mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-27 07:22:44 +02:00
convert pix fmt
Origin commit data
------------------
Branch: master
Commit: 0c14e1885d
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2017-11-17 (Fri, 17 Nov 2017)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -44,6 +44,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
#include <libswscale/swscale.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
|
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
|
||||||
@@ -193,13 +194,13 @@ void write_frame(AVFrame* in_frame, FILE* fp)
|
|||||||
av_packet_unref(&pkt);
|
av_packet_unref(&pkt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
avcodec_close(codec_context);
|
avcodec_close(codec_context);
|
||||||
av_free(codec_context);
|
av_free(codec_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int decode_frame(AVCodecContext *codecContext,AVPacket &packet, FILE* fp)
|
int decode_frame(AVCodecContext *codecContext,AVPacket &packet, FILE* fp)
|
||||||
{
|
{
|
||||||
@@ -210,8 +211,22 @@ int decode_frame(AVCodecContext *codecContext,AVPacket &packet, FILE* fp)
|
|||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
write_frame(frame, fp);
|
AVFrame *dest_frame = av_frame_alloc();
|
||||||
|
if(dest_frame){
|
||||||
|
dest_frame->height = (frame->height/2)*2;
|
||||||
|
dest_frame->width = (frame->width/2)*2;
|
||||||
|
dest_frame->format = AV_PIX_FMT_YUV420P;
|
||||||
|
av_frame_get_buffer(dest_frame, 32);
|
||||||
|
struct SwsContext *convert = NULL;
|
||||||
|
convert = sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format, dest_frame->width, dest_frame->height, AV_PIX_FMT_YUVJ420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
|
||||||
|
if(convert){
|
||||||
|
sws_scale(convert, frame->data, frame->linesize, 0, frame->height, dest_frame->data, dest_frame->linesize);
|
||||||
|
sws_freeContext(convert);
|
||||||
|
}
|
||||||
|
write_frame(dest_frame, fp);
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
|
av_frame_free(&dest_frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user