FFmpeg
|
Files | |
file | rational.h |
Data Structures | |
struct | AVRational |
Rational number (pair of numerator and denominator). More... | |
Functions | |
static AVRational | av_make_q (int num, int den) |
Create an AVRational. More... | |
static int | av_cmp_q (AVRational a, AVRational b) |
Compare two rationals. More... | |
static double | av_q2d (AVRational a) |
Convert an AVRational to a double . More... | |
int | av_reduce (int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max) |
Reduce a fraction. More... | |
AVRational | av_mul_q (AVRational b, AVRational c) av_const |
Multiply two rationals. More... | |
AVRational | av_div_q (AVRational b, AVRational c) av_const |
Divide one rational by another. More... | |
AVRational | av_add_q (AVRational b, AVRational c) av_const |
Add two rationals. More... | |
AVRational | av_sub_q (AVRational b, AVRational c) av_const |
Subtract one rational from another. More... | |
static av_always_inline AVRational | av_inv_q (AVRational q) |
Invert a rational. More... | |
AVRational | av_d2q (double d, int max) av_const |
Convert a double precision floating point number to a rational. More... | |
int | av_nearer_q (AVRational q, AVRational q1, AVRational q2) |
Find which of the two rationals is closer to another rational. More... | |
int | av_find_nearest_q_idx (AVRational q, const AVRational *q_list) |
Find the value in a list of rationals nearest a given reference rational. More... | |
uint32_t | av_q2intfloat (AVRational q) |
Convert an AVRational to a IEEE 32-bit float expressed in fixed-point format. More... | |
AVRational | av_gcd_q (AVRational a, AVRational b, int max_den, AVRational def) |
Return the best rational so that a and b are multiple of it. More... | |
Rational number calculation.
While rational numbers can be expressed as floating-point numbers, the conversion process is a lossy one, so are floating-point operations. On the other hand, the nature of FFmpeg demands highly accurate calculation of timestamps. This set of rational number utilities serves as a generic interface for manipulating rational numbers as pairs of numerators and denominators.
Many of the functions that operate on AVRational's have the suffix _q
, in reference to the mathematical symbol "ℚ" (Q) which denotes the set of all rational numbers.
|
inlinestatic |
Create an AVRational.
Useful for compilers that do not support compound literals.
Definition at line 71 of file rational.h.
Referenced by alloc_out_frame(), av_gcd_q(), avf_read_packet(), calculate_display_rect(), config_out_props(), config_output(), config_props(), convert_sub_to_old_ass_form(), encode_frame(), ff_decklink_read_header(), ff_decklink_set_format(), ff_framequeue_skip_samples(), ff_vorbiscomment_write(), filter_frame(), get_bmd_timecode(), get_frame_timecode(), get_next_nb_samples(), init(), init_output_stream_encode(), libdav1d_receive_frame(), mcc_read_header(), moflex_read_sync(), mov_metadata_hmmt(), mov_read_mdcv(), mov_read_sidx(), mov_read_smdm(), mxf_read_generic_descriptor(), mxf_write_header(), output_frame(), parse_manifest_representation(), plot_cqt(), push_frame(), decklink_input_callback::VideoInputFrameArrived(), viv_read_packet(), and viv_read_seek().
|
inlinestatic |
Compare two rationals.
a | First rational |
b | Second rational |
a == b
a > b
a < b
INT_MIN
if one of the values is of the form 0 / 0
Definition at line 89 of file rational.h.
Referenced by av_nearer_q(), av_opt_is_set_to_default(), av_timecode_get_smpte(), av_timecode_make_smpte_tc_string2(), calculate_display_rect(), compute_display_area(), compute_texture_rect(), config_input(), config_out_props(), config_output(), dash_init(), dump_stream_format(), ff_alloc_timecode_sei(), ff_decklink_set_format(), ff_h263_aspect_to_info(), ff_mpeg12_find_best_frame_rate(), ff_mxf_get_content_package_rate(), get_bmd_timecode(), get_frame_timecode(), h264_init_ps(), init_muxer(), main(), mkv_write_track(), mpeg_decode_postinit(), opengl_compute_display_area(), rescale_pts(), update_context_with_frame_header(), update_pts(), vaapi_encode_mpeg2_init_sequence_params(), decklink_input_callback::VideoInputFrameArrived(), write_adaptation_set(), and write_manifest().
|
inlinestatic |
Convert an AVRational to a double
.
a | AVRational to convert |
a
in floating-point form Definition at line 104 of file rational.h.
Referenced by audio_thread(), av_dump_format(), av_guess_frame_rate(), av_ts_make_time_string(), avformat_find_stream_info(), avformat_transfer_internal_stream_timing_info(), config_input(), config_output(), config_output_props(), config_props(), configure_video_device(), decode_frame(), decode_syncpoint(), DEFINE_BLEND8(), defined_frame_rate(), deshake_opencl_init(), do_blend(), do_video_out(), do_video_stats(), draw_text(), dump_dynamic_hdr_plus(), dump_mastering_display(), dump_mastering_display_metadata(), dump_stream_format(), dv_write_pack(), encode_frame(), fbdev_read_header(), fbdev_read_packet(), ff_decklink_set_format(), ff_determine_signal_peak(), ff_inlink_evaluate_timeline_at_frame(), ff_inlink_process_commands(), ff_mpv_encode_init(), ff_mpv_encode_picture(), ff_rfps_add_frame(), ff_rfps_calculate(), film_write_header(), filter_frame(), flv_init(), gdigrab_read_header(), gdigrab_read_packet(), geq_filter_frame(), get_best_frame(), get_fps(), get_video_frame(), init(), init_muxer(), init_output_stream_encode(), init_stream(), init_video(), main(), match_framerate(), mkv_write_trailer(), mkv_write_video_color(), mov_write_trak_tag(), mpegvideo_parse(), output_single_frame(), pkt_dump_internal(), process_input_packet(), put_videoinfoheader2(), read_header(), read_seek(), read_thread(), request_frame(), seg_write_packet(), segment_end(), select_frame(), set_side_data(), setts_filter(), stream_has_enough_packets(), svc_encode_init(), thp_read_header(), tonemap_vaapi_save_metadata(), v4l2_read_header(), vaapi_encode_h265_init_picture_params(), vaapi_encode_mpeg2_init_sequence_params(), video_thread(), write_adaptation_set(), write_manifest(), and writer_print_time().
Reduce a fraction.
This is useful for framerate calculations.
[out] | dst_num | Destination numerator |
[out] | dst_den | Destination denominator |
[in] | num | Source numerator |
[in] | den | Source denominator |
[in] | max | Maximum allowed values for dst_num & dst_den |
Definition at line 35 of file rational.c.
Referenced by aom_decode(), apng_write_header(), asf_read_header(), av1_metadata_update_sequence_header(), av_add_q(), av_d2q(), av_guess_sample_aspect_ratio(), av_mul_q(), av_parse_ratio(), avcodec_string(), avformat_find_stream_info(), avformat_transfer_internal_stream_timing_info(), avi_write_header(), avpriv_set_pts_info(), compute_dar(), config_input(), config_output(), cudascale_filter_frame(), dash_init(), decode_frame(), decode_sequence_header_adv(), dnxhd_decode_header(), dump_stream_format(), dxa_read_header(), export_stream_params(), ff_audio_resample_init(), ff_canopus_parse_info_tag(), ff_compute_frame_duration(), ff_mpv_encode_init(), ff_rfps_calculate(), ff_rm_read_mdpr_codecdata(), filter_frame(), flush_packet(), h264_metadata_update_sps(), h264_slice_header_init(), h265_metadata_update_sps(), h265_metadata_update_vps(), hevc_parse_slice_header(), init_output_stream_encode(), jp2_find_codestream(), jpeg_put_comments(), libdav1d_receive_frame(), libx265_encode_init(), mcc_read_header(), mkv_write_track(), mov_read_header(), mov_read_pasp(), mov_read_trak(), mov_write_pasp_tag(), mpeg2_metadata_update_fragment(), mpeg4_encode_vol_header(), mpeg_decode_postinit(), mxf_parse_dnxhd_frame(), mxf_parse_h264_frame(), mxf_parse_mpeg2_frame(), nppscale_filter_frame(), parse_video_var(), pcx_encode_frame(), put_videoinfoheader2(), qsvscale_filter_frame(), read_fps(), rebuild_filter_bank_with_compensation(), resample_init(), scale_frame(), set_context_with_sequence(), set_sar(), show_stream(), skeleton_header(), smacker_read_header(), svc_encode_init(), tmv_read_header(), update_context_with_frame_header(), vaapi_encode_h264_init_sequence_params(), vaapi_encode_h265_init_sequence_params(), vaapi_encode_init_rate_control(), vaapi_encode_mjpeg_init_picture_params(), vmd_read_header(), vtenc_create_encoder(), X264_init(), xvid_encode_frame(), yuv4_read_header(), and yuv4_write_header().
AVRational av_mul_q | ( | AVRational | b, |
AVRational | c | ||
) | const |
Multiply two rationals.
b | First rational |
c | Second rational |
Definition at line 80 of file rational.c.
Referenced by av1_parser_parse(), av_add_stable(), av_div_q(), avcodec_open2(), avformat_find_stream_info(), avi_write_header(), calculate_display_rect(), compute_display_area(), compute_pkt_fields(), compute_texture_rect(), config_input(), config_out_props(), config_output(), config_props(), cudascale_config_props(), decode_simple_internal(), decode_vol_header(), decode_vop_header(), deint_vaapi_config_output(), encode_frame(), ff_compute_frame_duration(), ff_mpeg12_find_best_frame_rate(), filter_frame(), h264_parse(), init_output_stream_encode(), init_output_stream_streamcopy(), mpeg_decode_postinit(), mpegvideo_extract_headers(), mxf_write_header(), nppscale_config_props(), opengl_compute_display_area(), put_videoinfoheader2(), qsvdeint_config_props(), qsvscale_config_props(), rv20_decode_picture_header(), scale_vaapi_config_output(), update_sar(), and vc1_extract_header().
AVRational av_div_q | ( | AVRational | b, |
AVRational | c | ||
) | const |
Divide one rational by another.
b | First rational |
c | Second rational |
Definition at line 88 of file rational.c.
Referenced by av_dv_codec_profile2(), av_guess_frame_rate(), avi_read_header(), build_frame_code(), config_input(), config_output(), config_output_props(), config_props(), config_props_output(), ff_mpeg12_find_best_frame_rate(), mediacodec_dec_parse_format(), mpeg_decode_postinit(), pad_opencl_config_output(), transpose_opencl_config_output(), vaapi_encode_mpeg2_init_sequence_params(), and write_adaptation_set().
AVRational av_add_q | ( | AVRational | b, |
AVRational | c | ||
) | const |
Add two rationals.
b | First rational |
c | Second rational |
Definition at line 93 of file rational.c.
Referenced by av_sub_q(), init_output_stream(), init_output_stream_streamcopy(), and main().
AVRational av_sub_q | ( | AVRational | b, |
AVRational | c | ||
) | const |
Subtract one rational from another.
b | First rational |
c | Second rational |
Definition at line 101 of file rational.c.
Referenced by main().
|
static |
Invert a rational.
q | value |
Definition at line 159 of file rational.h.
Referenced by activate(), av1_parser_parse(), avcodec_open2(), avformat_find_stream_info(), avformat_transfer_internal_stream_timing_info(), avi_read_header(), build_frame_code(), config_input(), config_output(), config_props(), config_video(), configure_input_video_filter(), dec_enc(), decode_simple_internal(), decode_vol_header(), decode_vop_header(), dshow_add_device(), dv_extract_timecode(), dv_extract_video_info(), dvvideo_decode_frame(), ff_compute_frame_duration(), ff_guess_coded_bitrate(), ff_rfps_calculate(), film_write_header(), filter_frame(), find_fps(), gdigrab_read_header(), guess_pkt_duration(), h264_parse(), init(), init_output_stream_encode(), init_src(), init_video_stream(), mf_encv_output_adjust(), mkv_write_track(), mov_create_timecode_track(), mov_parse_stsd_data(), mpegvideo_extract_headers(), mv_read_header(), mxf_compute_sample_count(), mxf_handle_missing_index_segment(), mxf_init_timecode(), mxf_parse_structural_metadata(), mxf_read_seek(), mxf_set_audio_pts(), mxf_set_current_edit_unit(), mxf_write_header(), open_output_file(), process_input_packet(), process_work_frame(), program_opencl_config_output(), r3d_read_rdvo(), r3d_seek(), read_header(), request_frame(), rm_write_header(), seek_to_start(), smush_read_header(), source_config_props(), try_push_frame(), txd_read_header(), vaapi_encode_mpeg2_init_sequence_params(), vc1_extract_header(), decklink_input_callback::VideoInputFrameArrived(), viv_read_seek(), vivo_read_header(), write_packet(), and yuv4_read_header().
AVRational av_d2q | ( | double | d, |
int | max | ||
) | const |
Convert a double precision floating point number to a rational.
In case of infinity, the returned value is expressed as {1, 0}
or {-1, 0}
depending on the sign.
d | double to convert |
max | Maximum allowed numerator and denominator |
d
in AVRational form Definition at line 106 of file rational.c.
Referenced by amf_parse_object(), av_opt_get_q(), av_opt_get_video_rate(), av_opt_is_set_to_default(), av_opt_set_defaults2(), av_parse_ratio(), config_output_props(), davs2_dump_frames(), decode_frame(), ff_update_hdr_metadata(), fourxm_read_header(), get_aspect_ratio(), microdvd_read_header(), mov_read_tkhd(), mov_read_trak(), mpeg_decode_postinit(), nuv_header(), opt_list(), read_header(), thp_read_header(), var_read_float(), vivo_read_header(), and write_number().
int av_nearer_q | ( | AVRational | q, |
AVRational | q1, | ||
AVRational | q2 | ||
) |
Find which of the two rationals is closer to another rational.
q | Rational to be compared against |
q1,q2 | Rationals to be tested |
q1
is nearer to q
than q2
q2
is nearer to q
than q1
Definition at line 127 of file rational.c.
Referenced by av_find_nearest_q_idx().
int av_find_nearest_q_idx | ( | AVRational | q, |
const AVRational * | q_list | ||
) |
Find the value in a list of rationals nearest a given reference rational.
q | Reference rational |
q_list | Array of rationals terminated by {0, 0} |
Definition at line 142 of file rational.c.
Referenced by init_output_stream_encode().
uint32_t av_q2intfloat | ( | AVRational | q | ) |
Convert an AVRational to a IEEE 32-bit float
expressed in fixed-point format.
q | Rational to be converted |
Definition at line 152 of file rational.c.
Referenced by ircam_write_header(), and main().
AVRational av_gcd_q | ( | AVRational | a, |
AVRational | b, | ||
int | max_den, | ||
AVRational | def | ||
) |
Return the best rational so that a and b are multiple of it.
If the resulting denominator is larger than max_den, return def.
Definition at line 186 of file rational.c.
Referenced by config_output(), and ff_framesync_configure().