summaryrefslogtreecommitdiffstats
path: root/video/decode/lavc.h
blob: 361153040058d0b98d10479dffb20b0dafdfc5f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef MPV_LAVC_H
#define MPV_LAVC_H

#include <stdbool.h>

#include <libavcodec/avcodec.h>

#include "config.h"

#include "demux/stheader.h"
#include "video/mp_image.h"

typedef struct lavc_ctx {
    AVCodecContext *avctx;
    AVFrame *pic;
    struct hwdec *hwdec;
    enum PixelFormat pix_fmt;
    int do_hw_dr1;
    int vo_initialized;
    int best_csp;
    struct mp_image_params image_params;
    AVRational last_sample_aspect_ratio;
    enum AVDiscard skip_frame;
    const char *software_fallback_decoder;

    // From VO
    struct mp_hwdec_info *hwdec_info;

    // For free use by hwdec implementation
    void *hwdec_priv;

    // Legacy
    bool do_dr1;
    struct FramePool *dr1_buffer_pool;
    struct mp_image_pool *non_dr1_pool;
} vd_ffmpeg_ctx;

struct vd_lavc_hwdec_functions {
    // If not-NULL, a 0 terminated list of IMGFMT_ formats. Only one of these
    // formats is accepted when handling the libavcodec get_format callback.
    const int *image_formats;
    int (*init)(struct lavc_ctx *ctx);
    void (*uninit)(struct lavc_ctx *ctx);
    struct mp_image *(*allocate_image)(struct lavc_ctx *ctx, AVFrame *frame);
    void (*fix_image)(struct lavc_ctx *ctx, struct mp_image *img);
};

// lavc_dr1.c
int mp_codec_get_buffer(AVCodecContext *s, AVFrame *frame);
void mp_codec_release_buffer(AVCodecContext *s, AVFrame *frame);
struct FrameBuffer;
void mp_buffer_ref(struct FrameBuffer *buffer);
void mp_buffer_unref(struct FrameBuffer *buffer);
bool mp_buffer_is_unique(struct FrameBuffer *buffer);
void mp_buffer_pool_free(struct FramePool **pool);

#endif