You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.2 KiB
28 lines
1.2 KiB
#include "sws.hpp"
|
|
|
|
extern "C" {
|
|
#include <libavformat/avformat.h>
|
|
#include <libavcodec/avcodec.h>
|
|
#include <libavformat/avformat.h>
|
|
#include <libswscale/swscale.h>
|
|
}
|
|
|
|
//auto sws_context = sws_getContext(input->width, input->height, av::get_format(input), frame_part->width, frame_part->height, av::get_format(frame_part), 0, nullptr, nullptr, nullptr);
|
|
//if(!sws_context) throw std::runtime_error("boem sws context");
|
|
//sws_scale (sws_context, {input->data}, {input->linesize}, 0, input->height, {frame_part->data}, {frame_part->linesize});
|
|
//sws_freeContext(sws_context);
|
|
|
|
namespace sws {
|
|
|
|
context create_context(av::frame const & src, av::frame const & dest, int flags, SwsFilter * src_filter, SwsFilter * dest_filter, double * params){
|
|
auto ptr = sws_getContext(src->width, src->height, av::get_format(src), dest->width, dest->height, av::get_format(dest), flags, src_filter, dest_filter, params);
|
|
if(!ptr) throw error("boem getContext");
|
|
return {ptr, &sws_freeContext};
|
|
}
|
|
|
|
void scale(context & c, av::frame const & src, av::frame & dest){
|
|
auto ret = sws_scale(c.get(), {src->data}, {src->linesize}, 0, src->height, {dest->data}, {dest->linesize});
|
|
if(ret < 0) throw error("boem scale");
|
|
}
|
|
|
|
}
|
|
|