digiKam
en265.h
Go to the documentation of this file.
1 /*
2  * H.265 video codec.
3  * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
4  *
5  * Authors: Dirk Farin <farin@struktur.de>
6  *
7  * This file is part of libde265.
8  *
9  * libde265 is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as
11  * published by the Free Software Foundation, either version 3 of
12  * the License, or (at your option) any later version.
13  *
14  * libde265 is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with libde265. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef EN265_H
24 #define EN265_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <libde265/de265.h>
31 
32 
33 // ========== encoder context ==========
34 
35 struct en265_encoder_context; // private structure
36 
37 /* Get a new encoder context. Must be freed with en265_free_encoder(). */
38 LIBDE265_API en265_encoder_context* en265_new_encoder(void);
39 
40 /* Free encoder context. May only be called once on a context. */
42 
43 /* The alloc_userdata pointer will be given to the release_func(). */
44 /*
45 LIBDE265_API void en265_set_image_release_function(en265_encoder_context*,
46  void (*release_func)(en265_encoder_context*,
47  struct de265_image*,
48  void* userdata),
49  void* alloc_userdata);
50 */
51 
52 // ========== encoder parameters ==========
53 
55  const char* parametername,int value);
57  const char* parametername,int value);
59  const char* parametername,const char* value);
61  const char* parametername,const char* value);
62 
63 
64 LIBDE265_API const char** en265_list_parameters(en265_encoder_context*);
65 
71 };
72 
74  const char* parametername);
75 
76 LIBDE265_API const char** en265_list_parameter_choices(en265_encoder_context*,
77  const char* parametername);
78 
79 
80 // --- convenience functions for command-line parameters ---
81 
83  int* argc, char** argv);
84 LIBDE265_API void en265_show_parameters(en265_encoder_context*);
85 
86 
87 
88 // ========== encoding loop ==========
89 
90 LIBDE265_API de265_error en265_start_encoder(en265_encoder_context*, int number_of_threads);
91 
92 // If we have provided our own memory release function, no image memory will be allocated.
93 LIBDE265_API struct de265_image* en265_allocate_image(en265_encoder_context*,
94  int width, int height,
95  enum de265_chroma chroma,
96  de265_PTS pts, void* image_userdata);
97 
98 LIBDE265_API void* de265_alloc_image_plane(struct de265_image* img, int cIdx,
99  void* inputdata, int inputstride, void *userdata);
100 LIBDE265_API void de265_free_image_plane(struct de265_image* img, int cIdx);
101 
102 
103 // Request a specification of the image memory layout for an image of the specified dimensions.
104 LIBDE265_API void en265_get_image_spec(en265_encoder_context*,
105  int width, int height, enum de265_chroma chroma,
106  struct de265_image_spec* out_spec);
107 
108 // Image memory layout specification for an image returned by en265_allocate_image().
109 /* TODO: do we need this?
110 LIBDE265_API void de265_get_image_spec_from_image(de265_image* img, struct de265_image_spec* spec);
111 */
112 
113 
115  struct de265_image*); // non-blocking
116 
117 LIBDE265_API de265_error en265_push_eof(en265_encoder_context*);
118 
119 // block when there are more than max_input_images in the input queue
121  int max_pending_images,
122  int timeout_ms);
123 
124 LIBDE265_API de265_error en265_trim_input_queue(en265_encoder_context*, int max_pending_images);
125 
126 LIBDE265_API int en265_current_input_queue_length(en265_encoder_context*);
127 
128 // Run encoder in main thread. Only use this when not using background threads.
129 LIBDE265_API de265_error en265_encode(en265_encoder_context*);
130 
132 {
138 };
139 
140 
142 
143 
151 };
152 
153 
180 };
181 
182 
184 {
185  int version; // currently: 1
186 
187  const uint8_t* data;
188  int length;
189 
191 
194  char final_slice : 1;
195  char dependent_slice : 1;
196 
198  unsigned char nuh_layer_id;
199  unsigned char nuh_temporal_id;
200 
201  en265_encoder_context* encoder_context;
202 
203  const struct de265_image* input_image;
205 };
206 
207 // timeout_ms - timeout in milliseconds. 0 - no timeout, -1 - block forever
208 LIBDE265_API struct en265_packet* en265_get_packet(en265_encoder_context*, int timeout_ms);
209 LIBDE265_API void en265_free_packet(en265_encoder_context*, struct en265_packet*);
210 
211 LIBDE265_API int en265_number_of_queued_packets(en265_encoder_context*);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 
218 #endif
int64_t de265_PTS
Definition: de265.h:166
de265_chroma
Definition: de265.h:159
#define LIBDE265_API
Definition: de265.h:52
de265_error
Definition: de265.h:82
LIBDE265_API struct en265_packet * en265_get_packet(en265_encoder_context *, int timeout_ms)
LIBDE265_API void * de265_alloc_image_plane(struct de265_image *img, int cIdx, void *inputdata, int inputstride, void *userdata)
LIBDE265_API de265_error en265_set_parameter_bool(en265_encoder_context *, const char *parametername, int value)
LIBDE265_API void en265_get_image_spec(en265_encoder_context *, int width, int height, enum de265_chroma chroma, struct de265_image_spec *out_spec)
LIBDE265_API enum en265_parameter_type en265_get_parameter_type(en265_encoder_context *, const char *parametername)
LIBDE265_API enum en265_encoder_state en265_get_encoder_state(en265_encoder_context *)
en265_encoder_state
Definition: en265.h:132
@ EN265_STATE_IDLE
Definition: en265.h:133
@ EN265_STATE_OUTPUT_QUEUE_FULL
Definition: en265.h:136
@ EN265_STATE_EOS
Definition: en265.h:137
@ EN265_STATE_WAITING_FOR_INPUT
Definition: en265.h:134
@ EN265_STATE_WORKING
Definition: en265.h:135
en265_packet_content_type
Definition: en265.h:144
@ EN265_PACKET_VPS
Definition: en265.h:145
@ EN265_PACKET_SEI
Definition: en265.h:148
@ EN265_PACKET_SKIPPED_IMAGE
Definition: en265.h:150
@ EN265_PACKET_SPS
Definition: en265.h:146
@ EN265_PACKET_SLICE
Definition: en265.h:149
@ EN265_PACKET_PPS
Definition: en265.h:147
LIBDE265_API de265_error en265_encode(en265_encoder_context *)
en265_parameter_type
Definition: en265.h:66
@ en265_parameter_string
Definition: en265.h:69
@ en265_parameter_choice
Definition: en265.h:70
@ en265_parameter_bool
Definition: en265.h:67
@ en265_parameter_int
Definition: en265.h:68
LIBDE265_API en265_encoder_context * en265_new_encoder(void)
LIBDE265_API de265_error en265_block_on_input_queue_length(en265_encoder_context *, int max_pending_images, int timeout_ms)
LIBDE265_API int en265_number_of_queued_packets(en265_encoder_context *)
LIBDE265_API de265_error en265_trim_input_queue(en265_encoder_context *, int max_pending_images)
LIBDE265_API de265_error en265_start_encoder(en265_encoder_context *, int number_of_threads)
LIBDE265_API int en265_current_input_queue_length(en265_encoder_context *)
LIBDE265_API de265_error en265_push_eof(en265_encoder_context *)
LIBDE265_API de265_error en265_set_parameter_choice(en265_encoder_context *, const char *parametername, const char *value)
LIBDE265_API const char ** en265_list_parameter_choices(en265_encoder_context *, const char *parametername)
LIBDE265_API de265_error en265_set_parameter_int(en265_encoder_context *, const char *parametername, int value)
LIBDE265_API de265_error en265_push_image(en265_encoder_context *, struct de265_image *)
LIBDE265_API void en265_show_parameters(en265_encoder_context *)
LIBDE265_API de265_error en265_set_parameter_string(en265_encoder_context *, const char *parametername, const char *value)
LIBDE265_API struct de265_image * en265_allocate_image(en265_encoder_context *, int width, int height, enum de265_chroma chroma, de265_PTS pts, void *image_userdata)
en265_nal_unit_type
Definition: en265.h:154
@ EN265_NUT_BLA_N_LP
Definition: en265.h:167
@ EN265_NUT_RADL_N
Definition: en265.h:161
@ EN265_NUT_SUFFIX_SEI
Definition: en265.h:179
@ EN265_NUT_SPS
Definition: en265.h:172
@ EN265_NUT_STSA_N
Definition: en265.h:159
@ EN265_NUT_RASL_N
Definition: en265.h:163
@ EN265_NUT_EOB
Definition: en265.h:176
@ EN265_NUT_TRAIL_N
Definition: en265.h:155
@ EN265_NUT_STSA_R
Definition: en265.h:160
@ EN265_NUT_VPS
Definition: en265.h:171
@ EN265_NUT_FD
Definition: en265.h:177
@ EN265_NUT_RADL_R
Definition: en265.h:162
@ EN265_NUT_BLA_W_RADL
Definition: en265.h:166
@ EN265_NUT_PREFIX_SEI
Definition: en265.h:178
@ EN265_NUT_PPS
Definition: en265.h:173
@ EN265_NUT_CRA
Definition: en265.h:170
@ EN265_NUT_TSA_R
Definition: en265.h:158
@ EN265_NUT_RASL_R
Definition: en265.h:164
@ EN265_NUT_TRAIL_R
Definition: en265.h:156
@ EN265_NUT_TSA_N
Definition: en265.h:157
@ EN265_NUT_IDR_W_RADL
Definition: en265.h:168
@ EN265_NUT_EOS
Definition: en265.h:175
@ EN265_NUT_BLA_W_LP
Definition: en265.h:165
@ EN265_NUT_AUD
Definition: en265.h:174
@ EN265_NUT_IDR_N_LP
Definition: en265.h:169
LIBDE265_API de265_error en265_parse_command_line_parameters(en265_encoder_context *, int *argc, char **argv)
LIBDE265_API de265_error en265_free_encoder(en265_encoder_context *)
LIBDE265_API const char ** en265_list_parameters(en265_encoder_context *)
LIBDE265_API void de265_free_image_plane(struct de265_image *img, int cIdx)
LIBDE265_API void en265_free_packet(en265_encoder_context *, struct en265_packet *)
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: de265.h:308
Definition: image.h:222
de265_PTS pts
Definition: image.h:423
Definition: en265.h:184
unsigned char nuh_layer_id
Definition: en265.h:198
const struct de265_image * reconstruction
Definition: en265.h:204
const uint8_t * data
Definition: en265.h:187
int version
Definition: en265.h:185
int length
Definition: en265.h:188
const struct de265_image * input_image
Definition: en265.h:203
char complete_picture
Definition: en265.h:193
enum en265_nal_unit_type nal_unit_type
Definition: en265.h:197
int frame_number
Definition: en265.h:190
en265_encoder_context * encoder_context
Definition: en265.h:201
char dependent_slice
Definition: en265.h:195
char final_slice
Definition: en265.h:194
unsigned char nuh_temporal_id
Definition: en265.h:199
enum en265_packet_content_type content_type
Definition: en265.h:192