FFmpeg  4.0
h265_metadata_bsf.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/common.h"
20 #include "libavutil/opt.h"
21 
22 #include "bsf.h"
23 #include "cbs.h"
24 #include "cbs_h265.h"
25 #include "hevc.h"
26 
27 enum {
31 };
32 
33 typedef struct H265MetadataContext {
34  const AVClass *class;
35 
38 
40 
41  int aud;
42 
44 
50 
52 
56 
57  int crop_left;
59  int crop_top;
62 
63 
65  H265RawVPS *vps)
66 {
68 
69  if (ctx->tick_rate.num && ctx->tick_rate.den) {
70  int num, den;
71 
72  av_reduce(&num, &den, ctx->tick_rate.num, ctx->tick_rate.den,
73  UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
74 
75  vps->vps_time_scale = num;
76  vps->vps_num_units_in_tick = den;
77 
79 
80  if (ctx->num_ticks_poc_diff_one > 0) {
82  ctx->num_ticks_poc_diff_one - 1;
84  } else if (ctx->num_ticks_poc_diff_one == 0) {
86  }
87  }
88 
89  return 0;
90 }
91 
93  H265RawSPS *sps)
94 {
96  int need_vui = 0;
97  int crop_unit_x, crop_unit_y;
98 
100  // Table E-1.
101  static const AVRational sar_idc[] = {
102  { 0, 0 }, // Unspecified (never written here).
103  { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
104  { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
105  { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
106  { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
107  };
108  int num, den, i;
109 
110  av_reduce(&num, &den, ctx->sample_aspect_ratio.num,
111  ctx->sample_aspect_ratio.den, 65535);
112 
113  for (i = 1; i < FF_ARRAY_ELEMS(sar_idc); i++) {
114  if (num == sar_idc[i].num &&
115  den == sar_idc[i].den)
116  break;
117  }
118  if (i == FF_ARRAY_ELEMS(sar_idc)) {
119  sps->vui.aspect_ratio_idc = 255;
120  sps->vui.sar_width = num;
121  sps->vui.sar_height = den;
122  } else {
123  sps->vui.aspect_ratio_idc = i;
124  }
126  need_vui = 1;
127  }
128 
129 #define SET_OR_INFER(field, value, present_flag, infer) do { \
130  if (value >= 0) { \
131  field = value; \
132  need_vui = 1; \
133  } else if (!present_flag) \
134  field = infer; \
135  } while (0)
136 
137  if (ctx->video_format >= 0 ||
138  ctx->video_full_range_flag >= 0 ||
139  ctx->colour_primaries >= 0 ||
140  ctx->transfer_characteristics >= 0 ||
141  ctx->matrix_coefficients >= 0) {
142 
145 
149 
150  if (ctx->colour_primaries >= 0 ||
151  ctx->transfer_characteristics >= 0 ||
152  ctx->matrix_coefficients >= 0) {
153 
155  ctx->colour_primaries,
157 
161 
163  ctx->matrix_coefficients,
165 
167  }
169  need_vui = 1;
170  }
171 
172  if (ctx->chroma_sample_loc_type >= 0) {
178  need_vui = 1;
179  }
180 
181  if (ctx->tick_rate.num && ctx->tick_rate.den) {
182  int num, den;
183 
184  av_reduce(&num, &den, ctx->tick_rate.num, ctx->tick_rate.den,
185  UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
186 
187  sps->vui.vui_time_scale = num;
188  sps->vui.vui_num_units_in_tick = den;
189 
191  need_vui = 1;
192 
193  if (ctx->num_ticks_poc_diff_one > 0) {
195  ctx->num_ticks_poc_diff_one - 1;
197  } else if (ctx->num_ticks_poc_diff_one == 0) {
199  }
200  }
201 
202  if (sps->separate_colour_plane_flag || sps->chroma_format_idc == 0) {
203  crop_unit_x = 1;
204  crop_unit_y = 1;
205  } else {
206  crop_unit_x = 1 + (sps->chroma_format_idc < 3);
207  crop_unit_y = 1 + (sps->chroma_format_idc < 2);
208  }
209 #define CROP(border, unit) do { \
210  if (ctx->crop_ ## border >= 0) { \
211  if (ctx->crop_ ## border % unit != 0) { \
212  av_log(bsf, AV_LOG_ERROR, "Invalid value for crop_%s: " \
213  "must be a multiple of %d.\n", #border, unit); \
214  return AVERROR(EINVAL); \
215  } \
216  sps->conf_win_ ## border ## _offset = \
217  ctx->crop_ ## border / unit; \
218  sps->conformance_window_flag = 1; \
219  } \
220  } while (0)
221  CROP(left, crop_unit_x);
222  CROP(right, crop_unit_x);
223  CROP(top, crop_unit_y);
224  CROP(bottom, crop_unit_y);
225 #undef CROP
226 
227  if (need_vui)
229 
230  return 0;
231 }
232 
234 {
236  AVPacket *in = NULL;
238  int err, i;
239 
240  err = ff_bsf_get_packet(bsf, &in);
241  if (err < 0)
242  return err;
243 
244  err = ff_cbs_read_packet(ctx->cbc, au, in);
245  if (err < 0) {
246  av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
247  goto fail;
248  }
249 
250  if (au->nb_units == 0) {
251  av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n");
252  err = AVERROR_INVALIDDATA;
253  goto fail;
254  }
255 
256  // If an AUD is present, it must be the first NAL unit.
257  if (au->units[0].type == HEVC_NAL_AUD) {
258  if (ctx->aud == REMOVE)
259  ff_cbs_delete_unit(ctx->cbc, au, 0);
260  } else {
261  if (ctx->aud == INSERT) {
262  H265RawAUD *aud = &ctx->aud_nal;
263  int pic_type = 0, temporal_id = 8, layer_id = 0;
264 
265  for (i = 0; i < au->nb_units; i++) {
266  const H265RawNALUnitHeader *nal = au->units[i].content;
267  if (!nal)
268  continue;
269  if (nal->nuh_temporal_id_plus1 < temporal_id + 1)
270  temporal_id = nal->nuh_temporal_id_plus1 - 1;
271 
272  if (au->units[i].type <= HEVC_NAL_RSV_VCL31) {
273  const H265RawSlice *slice = au->units[i].content;
274  layer_id = nal->nuh_layer_id;
275  if (slice->header.slice_type == HEVC_SLICE_B &&
276  pic_type < 2)
277  pic_type = 2;
278  if (slice->header.slice_type == HEVC_SLICE_P &&
279  pic_type < 1)
280  pic_type = 1;
281  }
282  }
283 
286  .nuh_layer_id = layer_id,
287  .nuh_temporal_id_plus1 = temporal_id + 1,
288  };
289  aud->pic_type = pic_type;
290 
291  err = ff_cbs_insert_unit_content(ctx->cbc, au,
292  0, HEVC_NAL_AUD, aud, NULL);
293  if (err) {
294  av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
295  goto fail;
296  }
297  }
298  }
299 
300  for (i = 0; i < au->nb_units; i++) {
301  if (au->units[i].type == HEVC_NAL_VPS) {
302  err = h265_metadata_update_vps(bsf, au->units[i].content);
303  if (err < 0)
304  goto fail;
305  }
306  if (au->units[i].type == HEVC_NAL_SPS) {
307  err = h265_metadata_update_sps(bsf, au->units[i].content);
308  if (err < 0)
309  goto fail;
310  }
311  }
312 
313  err = ff_cbs_write_packet(ctx->cbc, out, au);
314  if (err < 0) {
315  av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
316  goto fail;
317  }
318 
319  err = av_packet_copy_props(out, in);
320  if (err < 0)
321  goto fail;
322 
323  err = 0;
324 fail:
325  ff_cbs_fragment_uninit(ctx->cbc, au);
326 
327  if (err < 0)
328  av_packet_unref(out);
329  av_packet_free(&in);
330 
331  return err;
332 }
333 
335 {
338  int err, i;
339 
340  err = ff_cbs_init(&ctx->cbc, AV_CODEC_ID_HEVC, bsf);
341  if (err < 0)
342  return err;
343 
344  if (bsf->par_in->extradata) {
345  err = ff_cbs_read_extradata(ctx->cbc, au, bsf->par_in);
346  if (err < 0) {
347  av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
348  goto fail;
349  }
350 
351  for (i = 0; i < au->nb_units; i++) {
352  if (au->units[i].type == HEVC_NAL_VPS) {
353  err = h265_metadata_update_vps(bsf, au->units[i].content);
354  if (err < 0)
355  goto fail;
356  }
357  if (au->units[i].type == HEVC_NAL_SPS) {
358  err = h265_metadata_update_sps(bsf, au->units[i].content);
359  if (err < 0)
360  goto fail;
361  }
362  }
363 
364  err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, au);
365  if (err < 0) {
366  av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
367  goto fail;
368  }
369  }
370 
371  err = 0;
372 fail:
373  ff_cbs_fragment_uninit(ctx->cbc, au);
374  return err;
375 }
376 
378 {
380  ff_cbs_close(&ctx->cbc);
381 }
382 
383 #define OFFSET(x) offsetof(H265MetadataContext, x)
384 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
385 static const AVOption h265_metadata_options[] = {
386  { "aud", "Access Unit Delimiter NAL units",
388  { .i64 = PASS }, PASS, REMOVE, FLAGS, "aud" },
389  { "pass", NULL, 0, AV_OPT_TYPE_CONST,
390  { .i64 = PASS }, .flags = FLAGS, .unit = "aud" },
391  { "insert", NULL, 0, AV_OPT_TYPE_CONST,
392  { .i64 = INSERT }, .flags = FLAGS, .unit = "aud" },
393  { "remove", NULL, 0, AV_OPT_TYPE_CONST,
394  { .i64 = REMOVE }, .flags = FLAGS, .unit = "aud" },
395 
396  { "sample_aspect_ratio", "Set sample aspect ratio (table E-1)",
398  { .dbl = 0.0 }, 0, 65535, FLAGS },
399 
400  { "video_format", "Set video format (table E-2)",
402  { .i64 = -1 }, -1, 7, FLAGS },
403  { "video_full_range_flag", "Set video full range flag",
405  { .i64 = -1 }, -1, 1, FLAGS },
406  { "colour_primaries", "Set colour primaries (table E-3)",
408  { .i64 = -1 }, -1, 255, FLAGS },
409  { "transfer_characteristics", "Set transfer characteristics (table E-4)",
411  { .i64 = -1 }, -1, 255, FLAGS },
412  { "matrix_coefficients", "Set matrix coefficients (table E-5)",
414  { .i64 = -1 }, -1, 255, FLAGS },
415 
416  { "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
418  { .i64 = -1 }, -1, 6, FLAGS },
419 
420  { "tick_rate",
421  "Set VPS and VUI tick rate (num_units_in_tick / time_scale)",
423  { .dbl = 0.0 }, 0, UINT_MAX, FLAGS },
424  { "num_ticks_poc_diff_one",
425  "Set VPS and VUI number of ticks per POC increment",
427  { .i64 = -1 }, -1, INT_MAX, FLAGS },
428 
429  { "crop_left", "Set left border crop offset",
431  { .i64 = -1 }, -1, HEVC_MAX_WIDTH, FLAGS },
432  { "crop_right", "Set right border crop offset",
434  { .i64 = -1 }, -1, HEVC_MAX_WIDTH, FLAGS },
435  { "crop_top", "Set top border crop offset",
437  { .i64 = -1 }, -1, HEVC_MAX_HEIGHT, FLAGS },
438  { "crop_bottom", "Set bottom border crop offset",
440  { .i64 = -1 }, -1, HEVC_MAX_HEIGHT, FLAGS },
441 
442  { NULL }
443 };
444 
445 static const AVClass h265_metadata_class = {
446  .class_name = "h265_metadata_bsf",
447  .item_name = av_default_item_name,
448  .option = h265_metadata_options,
449  .version = LIBAVUTIL_VERSION_INT,
450 };
451 
452 static const enum AVCodecID h265_metadata_codec_ids[] = {
454 };
455 
457  .name = "hevc_metadata",
458  .priv_data_size = sizeof(H265MetadataContext),
459  .priv_class = &h265_metadata_class,
461  .close = &h265_metadata_close,
464 };
#define NULL
Definition: coverity.c:32
static enum AVCodecID h265_metadata_codec_ids[]
int nb_units
Number of units in this fragment.
Definition: cbs.h:144
uint8_t transfer_characteristics
Definition: cbs_h265.h:118
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVCodecParameters * par_out
Parameters of the output stream.
Definition: avcodec.h:5721
uint8_t vps_poc_proportional_to_timing_flag
Definition: cbs_h265.h:185
AVOption.
Definition: opt.h:246
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
int ff_cbs_write_packet(CodedBitstreamContext *ctx, AVPacket *pkt, CodedBitstreamFragment *frag)
Write the bitstream of a fragment to a packet.
Definition: cbs.c:320
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *out)
uint8_t vui_timing_info_present_flag
Definition: cbs_h265.h:135
int ff_cbs_init(CodedBitstreamContext **ctx_ptr, enum AVCodecID codec_id, void *log_ctx)
Create and initialise a new context for the given codec.
Definition: cbs.c:56
CodedBitstreamUnitType type
Codec-specific type of this unit.
Definition: cbs.h:67
int num
Numerator.
Definition: rational.h:59
The bitstream filter state.
Definition: avcodec.h:5687
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, AVBufferRef *content_buf)
Insert a new unit into a fragment with the given content.
Definition: cbs.c:518
uint8_t vui_parameters_present_flag
Definition: cbs_h265.h:287
void * priv_data
Opaque filter-specific private data.
Definition: avcodec.h:5708
uint32_t vps_num_units_in_tick
Definition: cbs_h265.h:183
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
static int h265_metadata_update_sps(AVBSFContext *bsf, H265RawSPS *sps)
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
Definition: cfhd.c:114
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:62
#define OFFSET(x)
static const AVOption h265_metadata_options[]
AVOptions.
uint8_t colour_primaries
Definition: cbs_h265.h:117
uint8_t video_format
Definition: cbs_h265.h:114
uint8_t vps_timing_info_present_flag
Definition: cbs_h265.h:182
int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt)
Read the data bitstream from a packet into a fragment, then split into units and decompose.
Definition: cbs.c:212
const char * name
Definition: avcodec.h:5737
uint8_t matrix_coefficients
Definition: cbs_h265.h:119
uint8_t aspect_ratio_info_present_flag
Definition: cbs_h265.h:105
uint8_t nuh_temporal_id_plus1
Definition: cbs_h265.h:33
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
void * content
Pointer to the decomposed form of this unit.
Definition: cbs.h:99
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units.
Definition: cbs.h:150
uint8_t video_full_range_flag
Definition: cbs_h265.h:115
#define av_log(a,...)
uint8_t chroma_sample_loc_type_bottom_field
Definition: cbs_h265.h:123
uint8_t video_signal_type_present_flag
Definition: cbs_h265.h:113
H265RawVUI vui
Definition: cbs_h265.h:288
uint32_t vui_num_ticks_poc_diff_one_minus1
Definition: cbs_h265.h:139
static void h265_metadata_close(AVBSFContext *bsf)
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:215
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
uint8_t nuh_layer_id
Definition: cbs_h265.h:32
void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Free all allocated memory in a fragment.
Definition: cbs.c:121
uint8_t chroma_loc_info_present_flag
Definition: cbs_h265.h:121
uint16_t sar_height
Definition: cbs_h265.h:108
#define fail()
Definition: checkasm.h:116
uint8_t chroma_sample_loc_type_top_field
Definition: cbs_h265.h:122
uint32_t vui_time_scale
Definition: cbs_h265.h:137
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:415
uint8_t slice_type
Definition: cbs_h265.h:431
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
Definition: avpacket.c:558
int ff_cbs_write_extradata(CodedBitstreamContext *ctx, AVCodecParameters *par, CodedBitstreamFragment *frag)
Write the bitstream of a fragment to the extradata in codec parameters.
Definition: cbs.c:295
uint8_t pic_type
Definition: cbs_h265.h:417
uint16_t sar_width
Definition: cbs_h265.h:107
AVFormatContext * ctx
Definition: movenc.c:48
int ff_cbs_delete_unit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position)
Delete a unit from a fragment and free all memory it uses.
Definition: cbs.c:592
static int h265_metadata_init(AVBSFContext *bsf)
#define FF_ARRAY_ELEMS(a)
CodedBitstreamContext * cbc
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:114
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:592
uint32_t vui_num_units_in_tick
Definition: cbs_h265.h:136
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
CodedBitstreamFragment access_unit
Describe the class of an AVClass context structure.
Definition: log.h:67
Context structure for coded bitstream operations.
Definition: cbs.h:156
Rational number (pair of numerator and denominator).
Definition: rational.h:58
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
uint8_t chroma_format_idc
Definition: cbs_h265.h:233
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:95
int ff_cbs_read_extradata(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecParameters *par)
Read the extradata bitstream found in codec parameters into a fragment, then split into units and dec...
Definition: cbs.c:170
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
#define CROP(border, unit)
uint8_t vui_poc_proportional_to_timing_flag
Definition: cbs_h265.h:138
const AVBitStreamFilter ff_hevc_metadata_bsf
common internal and external API header
static enum AVCodecID codec_ids[]
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
Called by the bitstream filters to get the next packet for filtering.
Definition: bsf.c:206
static const AVClass h265_metadata_class
int den
Denominator.
Definition: rational.h:60
#define SET_OR_INFER(field, value, present_flag, infer)
static int h265_metadata_update_vps(AVBSFContext *bsf, H265RawVPS *vps)
H265RawSliceHeader header
Definition: cbs_h265.h:511
uint32_t vps_time_scale
Definition: cbs_h265.h:184
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: avcodec.h:3898
uint8_t aspect_ratio_idc
Definition: cbs_h265.h:106
FILE * out
Definition: movenc.c:54
AVRational sample_aspect_ratio
uint32_t vps_num_ticks_poc_diff_one_minus1
Definition: cbs_h265.h:186
uint8_t separate_colour_plane_flag
Definition: cbs_h265.h:234
uint8_t colour_description_present_flag
Definition: cbs_h265.h:116
#define FLAGS
This structure stores compressed data.
Definition: avcodec.h:1407
AVCodecParameters * par_in
Parameters of the input stream.
Definition: avcodec.h:5715
uint8_t nal_unit_type
Definition: cbs_h265.h:31