summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLyon Wang <lyon.wang@freescale.com>2015-05-12 15:47:33 +0800
committerTim-Philipp Müller <tim@centricular.com>2015-05-13 11:51:20 +0100
commit6adf3c2499f81e9254e160e04ce3c821bd47938d (patch)
tree0258e93a40f1e20a70627306c46a050ef908bde0
parentc51916905293587f090f172c3971209e4af971dd (diff)
downloadgstreamer-plugins-bad-6adf3c2499f81e9254e160e04ce3c821bd47938d.tar.gz
h263parse: fix custom picture format (CPFMT) parsing
In the H263 spec, CPFMT is present only if the use of a custom picture format is signalled in PLUSEPTYPE and UFEP is "001", so we need to check params->format and only if the value is 6 (custom source format) the CPFMT should be read, otherwise it's not present and wrong data will be parsed. When reading the CPFMT, the width and height were not calculated correctly (wrong bitmask). https://bugzilla.gnome.org//show_bug.cgi?id=749253
-rw-r--r--gst/videoparsers/h263parse.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/gst/videoparsers/h263parse.c b/gst/videoparsers/h263parse.c
index d794f7aed..98a30e797 100644
--- a/gst/videoparsers/h263parse.c
+++ b/gst/videoparsers/h263parse.c
@@ -271,29 +271,46 @@ gst_h263_parse_get_params (H263Params * params, GstBuffer * buffer,
}
if (ufep == 1) {
- guint32 cpfmt = 0;
+ if (params->format == 6) {
+ /* A fixed length codeword of 23 bits that is present only if the use of
+ * a custom picture format is signalled in PLUSPTYPE and UFEP is 001 */
+ guint32 cpfmt = 0;
- /* 5.1.5 CPFMT : Custom Picture Format (23 bits) */
- if (!gst_bit_reader_get_bits_uint32 (&br, &cpfmt, 23))
- goto more;
- if (!(cpfmt & 0x200)) {
- GST_WARNING ("Corrupted CPFMT (0x%x)", cpfmt);
- goto beach;
- }
- temp8 = cpfmt >> 19;
- params->width = (((cpfmt >> 10) & 0x1f) + 1) * 4;
- params->height = ((cpfmt & 0x1f) + 1) * 4;
-
- if (temp8 == 0xf) {
- guint32 epar = 0;
- /* 5.1.6 EPAR : Extended Pixel Aspect Ratio (16bits) */
- if (!gst_bit_reader_get_bits_uint32 (&br, &epar, 16))
+ /* 5.1.5 CPFMT : Custom Picture Format (23 bits) */
+ if (!gst_bit_reader_get_bits_uint32 (&br, &cpfmt, 23))
goto more;
- params->parnum = epar >> 8;
- params->pardenom = epar & 0xf;
+ if (!(cpfmt & 0x200)) {
+ GST_WARNING ("Corrupted CPFMT (0x%x)", cpfmt);
+ goto beach;
+ }
+ temp8 = cpfmt >> 19;
+ /* Bits 5-13: Picture Width Indication: Range [0, ... , 511];
+ * Number of pixels per line = (PWI + 1) * 4 */
+ params->width = (((cpfmt >> 10) & 0x1ff) + 1) * 4;
+ /* Bits 15-23 Picture Height Indication: Range [1, ... , 288];
+ * Number of lines = PHI * 4 */
+ params->height = (cpfmt & 0x1ff) * 4;
+
+ if (temp8 == 0xf) {
+ guint32 epar = 0;
+ /* 5.1.6 EPAR : Extended Pixel Aspect Ratio (16bits) */
+ if (!gst_bit_reader_get_bits_uint32 (&br, &epar, 16))
+ goto more;
+ params->parnum = epar >> 8;
+ params->pardenom = epar & 0xf;
+ } else {
+ params->parnum = partable[temp8][0];
+ params->pardenom = partable[temp8][1];
+ }
} else {
- params->parnum = partable[temp8][0];
- params->pardenom = partable[temp8][1];
+ /* Fill in width/height based on format */
+ params->width = sizetable[params->format][0];
+ params->height = sizetable[params->format][1];
+ GST_DEBUG (" Picture width x height: %d x %d",
+ params->width, params->height);
+ /* Fill in default Pixel aspect ratios */
+ params->parnum = 12;
+ params->pardenom = 11;
}
if (params->custompcfpresent) {