X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fimage_input.cpp;h=316292b15d7ffd01428eb2d7a165834278fe1fc7;hb=f81ae3be1aae619fe4ad022f55d95a4a83ace076;hp=6a2c5abc846b913123ef00647373bd6267ee1d4b;hpb=337e2d06624b4b46eb2e7e5365e2ece219f9f100;p=nageru diff --git a/nageru/image_input.cpp b/nageru/image_input.cpp index 6a2c5ab..316292b 100644 --- a/nageru/image_input.cpp +++ b/nageru/image_input.cpp @@ -1,15 +1,32 @@ #include "image_input.h" +#include +#include +#include +#include #include -#include +#include +#include +#include #include #include +#include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include +#include extern "C" { +#include +#include #include #include #include @@ -21,21 +38,11 @@ extern "C" { #include } -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include "ffmpeg_util.h" #include "shared/context.h" #include "shared/ffmpeg_raii.h" -#include "ffmpeg_util.h" -#include "flags.h" +#include "shared/ref_counted_texture.h" +#include "tweaked_inputs.h" struct SwsContext; @@ -126,7 +133,7 @@ shared_ptr ImageInput::load_image_raw(const string &pat fprintf(stderr, "%s: Cannot fill codec parameters\n", pathname.c_str()); return nullptr; } - AVCodec *codec = avcodec_find_decoder(codecpar->codec_id); + const AVCodec *codec = avcodec_find_decoder(codecpar->codec_id); if (codec == nullptr) { fprintf(stderr, "%s: Cannot find decoder\n", pathname.c_str()); return nullptr; @@ -143,17 +150,14 @@ shared_ptr ImageInput::load_image_raw(const string &pat AVFrameWithDeleter frame = av_frame_alloc_unique(); bool eof = false; do { - AVPacket pkt; - unique_ptr pkt_cleanup( - &pkt, av_packet_unref); - av_init_packet(&pkt); - pkt.data = nullptr; - pkt.size = 0; - if (av_read_frame(format_ctx.get(), &pkt) == 0) { - if (pkt.stream_index != stream_index) { + AVPacketWithDeleter pkt = av_packet_alloc_unique(); + pkt->data = nullptr; + pkt->size = 0; + if (av_read_frame(format_ctx.get(), pkt.get()) == 0) { + if (pkt->stream_index != stream_index) { continue; } - if (avcodec_send_packet(codec_ctx.get(), &pkt) < 0) { + if (avcodec_send_packet(codec_ctx.get(), pkt.get()) < 0) { fprintf(stderr, "%s: Cannot send packet to codec.\n", pathname.c_str()); return nullptr; } @@ -228,7 +232,7 @@ shared_ptr ImageInput::load_image_raw(const string &pat glBindTexture(GL_TEXTURE_2D, 0); check_error(); - shared_ptr image(new Image{unsigned(frame->width), unsigned(frame->height), RefCountedTexture(new GLuint(tex)), last_modified}); + shared_ptr image(new Image{unsigned(frame->width), unsigned(frame->height), UniqueTexture(new GLuint(tex)), last_modified}); return image; }