mpeg1_2_video_packetizer_c:: mpeg1_2_video_packetizer_c(generic_reader_c *p_reader, track_info_c &p_ti, int version, double fps, int width, int height, int dwidth, int dheight, bool framed) : video_packetizer_c(p_reader, p_ti, "V_MPEG1", fps, width, height) , m_framed(framed) , m_aspect_ratio_extracted(true) { set_codec_id((boost::format("V_MPEG%1%") % version).str()); if (!display_dimensions_or_aspect_ratio_set()) { if ((0 < dwidth) && (0 < dheight)) set_video_display_dimensions(dwidth, dheight, PARAMETER_SOURCE_BITSTREAM); else m_aspect_ratio_extracted = false; } m_timecode_factory_application_mode = TFA_SHORT_QUEUEING; // m_parser.SeparateSequenceHeaders(); }
void theora_video_packetizer_c::extract_aspect_ratio() { if (display_dimensions_or_aspect_ratio_set() || (NULL == m_ti.m_private_data) || (0 == m_ti.m_private_size)) return; memory_cptr private_data = memory_cptr(new memory_c(m_ti.m_private_data, m_ti.m_private_size, false)); std::vector<memory_cptr> packets = unlace_memory_xiph(private_data); for (auto &packet : packets) { if ((0 == packet->get_size()) || (THEORA_HEADERTYPE_IDENTIFICATION != packet->get_buffer()[0])) continue; try { theora_identification_header_t theora; theora_parse_identification_header(packet->get_buffer(), packet->get_size(), theora); if ((0 == theora.display_width) || (0 == theora.display_height)) return; set_video_display_dimensions(theora.display_width, theora.display_height, PARAMETER_SOURCE_BITSTREAM); mxinfo_tid(m_ti.m_fname, m_ti.m_id, boost::format(Y("Extracted the aspect ratio information from the Theora video headers and set the display dimensions to %1%/%2%.\n")) % theora.display_width % theora.display_height); } catch (...) { } return; } }
void mpeg4_p2_video_packetizer_c::extract_aspect_ratio(const unsigned char *buffer, int size) { if (m_aspect_ratio_extracted) return; if ((0 != m_connected_to) || display_dimensions_or_aspect_ratio_set()) { m_aspect_ratio_extracted = true; return; } uint32_t num, den; if (mpeg4::p2::extract_par(buffer, size, num, den)) { m_aspect_ratio_extracted = true; set_video_aspect_ratio((double)m_hvideo_pixel_width / (double)m_hvideo_pixel_height * (double)num / (double)den, false, OPTION_SOURCE_BITSTREAM); generic_packetizer_c::set_headers(); rerender_track_headers(); mxinfo_tid(m_ti.m_fname, m_ti.m_id, boost::format(Y("Extracted the aspect ratio information from the MPEG4 layer 2 video data and set the display dimensions to %1%/%2%.\n")) % m_hvideo_display_width % m_hvideo_display_height); } else if (50 <= m_frames_output) m_aspect_ratio_extracted = true; }
mpeg1_2_video_packetizer_c:: mpeg1_2_video_packetizer_c(generic_reader_c *p_reader, track_info_c &p_ti, int version, double fps, int width, int height, int dwidth, int dheight, bool framed) : generic_video_packetizer_c{p_reader, p_ti, "V_MPEG1", fps, width, height} , m_framed{framed} , m_aspect_ratio_extracted{true} , m_num_removed_stuffing_bytes{} , m_debug_stuffing_removal{"mpeg1_2|mpeg1_2_stuffing_removal"} { set_codec_id((boost::format("V_MPEG%1%") % version).str()); if (!display_dimensions_or_aspect_ratio_set()) { if ((0 < dwidth) && (0 < dheight)) set_video_display_dimensions(dwidth, dheight, OPTION_SOURCE_BITSTREAM); else m_aspect_ratio_extracted = false; } m_timestamp_factory_application_mode = TFA_SHORT_QUEUEING; // m_parser.SeparateSequenceHeaders(); }
void generic_packetizer_c::set_video_aspect_ratio(double aspect_ratio, bool is_factor, option_source_e source) { if (display_dimensions_or_aspect_ratio_set() && (m_ti.m_display_dimensions_source >= source)) return; m_ti.m_aspect_ratio = aspect_ratio; m_ti.m_aspect_ratio_is_factor = is_factor; m_ti.m_display_dimensions_source = source; m_ti.m_display_dimensions_given = false; m_ti.m_aspect_ratio_given = true; }
void mpeg1_2_video_packetizer_c::extract_aspect_ratio(const unsigned char *buffer, int size) { float ar; if (display_dimensions_or_aspect_ratio_set()) return; if (!mpeg1_2::extract_ar(buffer, size, ar)) return; set_video_display_dimensions((0 >= ar) || (1 == ar) ? m_width : (int)(m_height * ar), m_height, PARAMETER_SOURCE_BITSTREAM); rerender_track_headers(); m_aspect_ratio_extracted = true; }
void generic_packetizer_c::set_video_display_dimensions(int width, int height, option_source_e source) { if (display_dimensions_or_aspect_ratio_set() && (m_ti.m_display_dimensions_source >= source)) return; m_ti.m_display_width = width; m_ti.m_display_height = height; m_ti.m_display_dimensions_source = source; m_ti.m_display_dimensions_given = true; m_ti.m_aspect_ratio_given = false; set_video_display_width(width); set_video_display_height(height); }
void mpeg4_p10_video_packetizer_c::extract_aspect_ratio() { auto result = mpeg4::p10::extract_par(m_ti.m_private_data); set_codec_private(result.new_avcc); if (!result.is_valid() || display_dimensions_or_aspect_ratio_set()) return; auto par = static_cast<double>(result.numerator) / static_cast<double>(result.denominator); set_video_display_dimensions(1 <= par ? std::llround(m_width * par) : m_width, 1 <= par ? m_height : std::llround(m_height / par), OPTION_SOURCE_BITSTREAM); mxinfo_tid(m_ti.m_fname, m_ti.m_id, boost::format(Y("Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to %1%/%2%.\n")) % m_ti.m_display_width % m_ti.m_display_height); }