hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * Copyright 2021 Rockchip Electronics Co., Ltd
 *     Author: Jeffy Chen <jeffy.chen@rock-chips.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */
 
#ifndef  __GST_MPP_DEC_H__
#define  __GST_MPP_DEC_H__
 
#include <gst/video/gstvideodecoder.h>
 
#include "gstmpp.h"
 
G_BEGIN_DECLS;
 
#define GST_TYPE_MPP_DEC    (gst_mpp_dec_get_type())
#define GST_MPP_DEC(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MPP_DEC, GstMppDec))
#define GST_MPP_DEC_CLASS(klass) \
   (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_MPP_DEC, GstMppDecClass))
typedef struct _GstMppDec GstMppDec;
typedef struct _GstMppDecClass GstMppDecClass;
 
struct _GstMppDec
{
  GstVideoDecoder parent;
 
  GMutex mutex;
  GstAllocator *allocator;
  GstVideoCodecState *input_state;
 
  /* final output video info */
  GstVideoInfo info;
 
  /* specified output format */
  GstVideoFormat format;
 
  gboolean convert;
  gint rotation;
  gint width;
  gint height;
 
  guint crop_x, crop_y, crop_w, crop_h;
 
  gboolean arm_afbc;
 
  gboolean ignore_error;
 
  gboolean fast_mode;
 
  /* stop handling new frame when flushing */
  gboolean flushing;
 
  /* drop frames when flushing but not draining */
  gboolean draining;
 
  /* flow return from pad task */
  GstFlowReturn task_ret;
 
  GstVideoInterlaceMode interlace_mode;
 
  /* seen valid PTS in input frames */
  gboolean seen_valid_pts;
 
  /* for using MPP generated PTS */
  gboolean use_mpp_pts;
  GstClockTime mpp_delta_pts;
 
  guint32 decoded_frames;
 
  MppCodingType mpp_type;
  MppCtx mpp_ctx;
  MppApi *mpi;
};
 
struct _GstMppDecClass
{
  GstVideoDecoderClass parent_class;
 
    gboolean (*startup) (GstVideoDecoder * decoder);
    MppPacket (*get_mpp_packet) (GstVideoDecoder * decoder,
      GstMapInfo * mapinfo);
    gboolean (*send_mpp_packet) (GstVideoDecoder * decoder,
      MppPacket mpkt, gint timeout_ms);
    MppFrame (*poll_mpp_frame) (GstVideoDecoder * decoder, gint timeout_ms);
    gboolean (*shutdown) (GstVideoDecoder * decoder, gboolean drain);
};
 
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstMppDec, gst_object_unref);
GType gst_mpp_dec_get_type (void);
 
#define GST_FLOW_TIMEOUT GST_FLOW_CUSTOM_ERROR_1
 
#define MPP_DEC_OUT_FORMATS "NV12, NV16, NV12_10LE40"
 
#ifdef HAVE_RGA
#define MPP_DEC_FORMATS MPP_DEC_OUT_FORMATS "," GST_RGA_FORMATS
#else
#define MPP_DEC_FORMATS MPP_DEC_OUT_FORMATS
#endif
 
#define MPP_DEC_FEATURE_ARM_AFBC "arm-afbc"
 
void gst_mpp_dec_fixup_video_info (GstVideoDecoder * decoder,
    GstVideoFormat format, gint width, gint height);
 
gboolean gst_mpp_dec_update_simple_video_info (GstVideoDecoder * decoder,
    GstVideoFormat format, guint width, guint height, guint align);
 
G_END_DECLS;
 
#endif /* __GST_MPP_DEC_H__ */