Video Coding Video Coding
Total Page:16
File Type:pdf, Size:1020Kb
Course INF5081 Multimedia Coding and Applications Video Coding Ifi,10110100 UiO Norsk Regnesentral Vårsemester 2008 Wolfgang Leister Video Coding Authors ... • Wolfgang Leister • Peter Oel, • Clemens Knoerzer 110100 Video Coding The story so far ... • Data compression – information theory – run length encoding – Huffman coding – Zif-Lempel(-Welch) algorithm – Arithmetic coding • Colour coding and raster images 110100 Video Coding Overview • Video Formats – Container Formats: AVI,QuickTime –MJPEG – H.261 – MPEG I, II – MPEG TS – H.263 110100 Video Coding AVI • Audio Video Interleaved, by Microsoft, 1992 • specialisation of RIFF – Resource Interchange File Format • Container-Format for Audio and Video • File consists of blocks (chunks) – Each chunk characterised by 4 letters – format: ID (4Byte) length (4 Byte) data – Each chunk can contain sub-chunks. • Outdated, but still in use 110100 Video Coding QuickTime • Container-Format and MM Framework – By Apple Inc. – Originally developed for Macintosh • Start: Charles Wiltgen, 1992 • Currently: Quicktime 7.x 110100 Video Coding Quicktime Audio • Apple Lossless • QDesign Music • Audio Interchange (AIFF) • Qualcomm PureVoice • Digital Audio: Audio CD - 16- (QCELP) bit (CDDA), 24-bit, 32-bit • Sun AU Audio integer & floating point, and • ULAW and ALAW Audio 64-bit floating point • Waveform Audio (WAV) • MIDI • MPEG-1 Layer 3 Audio (.mp3) • MPEG-4 AAC Audio (m4a, .m4b, m4p) • 110100 Video Coding Quicktime Video • 3GPP & 3GPP2 file formats • JPEG, Photo JPEG, and JPEG-2000 • AVI file format • Quartz Composer Composition • Bitmap (BMP) codec and file • QuickTime Movie (.mov) and QTVR format movies • DV file (DV NTSC/PAL and DVC • Sorenson Video 2 and 3 codecs Pro NTSC/PAL codecs) • Apple Video, Cinepak, • Flash & FlashPix files • Component Video, Graphics, Planar • GIF and Animated GIF files RGB • H.261, H.263, and H.264 codecs • still image formats: PNG, TIFF, TGA • MPEG-1, MPEG-2, MPEG-4, • Cached information from streams: QTCH AVC 110100 Video Coding MJPEG • Motion-JPEG • Sequence of JPEG-Frames • not a standard • many proprietary formats – e.g., AVI and QuickTime • only Baseline-JPEG • audio track(s) 110100 Video Coding MJPEG • Compression as in JPEG • Temporal dependencies are not used. • suitable for video cutting software: – cut is possible at each frame – no quality decrease when cutting • Hardware support possible! 110100 Video Coding MJPEG by Parallax ... example Offset1 Offset2 ... Offsetn Offset1 Header Offset2 Frame Frame ... Frame ... Pointer to Index Offsetn Video- data Load Video EoFrame Frame Video- Audio- data data Load Video Load Audio 110100EoFrame Video Coding MJPEG by Parallax • Header contains: – Id / Version – Frames per second / number of frames – Width / Height – Bandwidth – Quantising factor – Number of Audio Tracks / Sampling Rate – Offset of frame index 110100 Video Coding ITU-T / CCITT • Standardisation Organisation – CCITT (Commité Consultatif International de Télécommunications et Télégraphique) – ITU-T (International Telecommunication Union) 110100 Video Coding H.261 • Video Codec for Audiovisual Services – Image telephony / video conferences – Adapted for ISDN (p x 64 kbit/s) – Constant data rate by feedback • 4:2:0 Sampling (Chrominance-channels with half the resolution of luminance channel (number of rows and columns)) • Resolutions: – CIF: 352 x 288 (Common Intermediate 110100Format) –Video Coding QCIF: 176 x 144 (Quarter CIF) Subsampling • A:B:C Notion of CCIR-601 • 4:2:2 horizontal 2:1 downsampling of colour channels • 4:1:1 horizontal 4:1 downsampling of colour channels • 4:2:0 horizontal and vertical 2:1 downsampling of colour channels 110100 Video Coding Example YCb, Cr each 4:2:2 352 x 288 176 x 288 4:1:1 352 x 288 88 x 288 4:2:0 352 x 288 176 x 144 110100 Video Coding Example 4:2:2 C Cr C Cr C Cr Y b Y Y b Y Y b Y C Cr C Cr C Cr Y b Y Y b Y Y b Y C Cr C Cr C Cr Y b Y Y b Y Y b Y C Cr C Cr C Cr Y b Y Y b Y Y b Y 110100 Video Coding Example 4:2:0 Y Y Y Y Y Y C C C Cb r Cb r Cb r Y Y Y Y Y Y Y Y Y Y Y Y C C C Cb r Cb r Cb r Y Y Y Y Y Y 110100 Video Coding H.261 Two frame types: • IntraFrames – Very similar to JPEG-Image (DCT, Quantising, Coding) • InterFrames – Code differences to previous frame. – Movements are compensated by motion- estimation. 110100 Video Coding Intra- / InterFrames IntraFrame IntraFrame InterFrames InterFrames 110100 Video Coding Motion Estimation 110100 Video Coding Motion-Estimation 110100 Video Coding H.261 • Motion-Vector max. ±15 Pixels • all DCT-Coefficients are quantised with same value • Quantising controled by output stream (feedback). • Quantising has dead zone 110100 Video Coding H.261 data layout 110100 Video Coding MPEG • Motion Picture Expert Group • ISO/IEC 11172 (MPEG-1) • ISO/IEC 13818 (MPEG-2) • Video / Audio compression and coding 110100 Video Coding MPEG History • MPEG-1: video and audio (1992) • MPEG-2: Digital TV and DVD (1994) • MPEG-3: HDTV (withdrawn) • MPEG-4: Multimedia applications (1998) • MPEG-7: MM search and filtering (2001) • MPEG-21: Multimedia framework 110100 Video Coding MPEG History • MPEG-1: video and audio (1992) • MPEG-2: Digital TV and DVD (1994) • MPEG-3: HDTV (withdrawn) • MPEG-4: Multimedia applications (1998) • MPEG-7: MM search and filtering (2001) • MPEG-21: Multimedia framework 110100 Video Coding MPEG-1 • ISO 11172 • Part 1: Systems • Part 2: Video • Part 3: Audio (Layer I, II, III) • Part 4: Conformance • Part 5: Software Simulation 110100 Video Coding MPEG-2 • ISO 13818 • Parts 1-5 as in MPEG-1 • Part 6: DSM-CC (Digital Storage Medium Command and Control) • Part 7: NBC (Non-Backwards Compatible Audio) • Part 8: 10-bit video extension (withdrawn) • Part 9: RTI (Real-time interface between set-top box and head end server) 110100 Video Coding MPEG Which parts of MPEG 2 are of interest for this course? • Part 2: Video • Part 3: Audio (Layer I, II, III) • Part 1: Systems • Part 6: DSM-CC 110100 Video Coding MP3 = MPEG-1 Audio Layer 3 110100 Video Coding ! MPEG • Differences to H.261 – Motion-Vectors not limited to ±15 Pixels – Motion-Vektors not necessarily integer numbers – 3 (4) Frame-Types (I-, P-, B-Frames) – Data stream not limited to p x 64 kbit/s. – Quantising of coefficients with matrix 110100 Video Coding Macro blocks • Adjacent 8x8-Blocks of channels are joined to macro blocks. • Depending on sub sampling several 8x8 blocks are in one macro block 110100 Video Coding MPEG • Frame-Types: – I-Frame: Like IntraFrames of H.261 (ca. every 15. Frame) – P-Frame: Like InterFrames of H.261 (Predicted Frame). Related to previous I or P-Frame – B-Frame: (Bidirectional predicted Frame) No equivalent of H.261. Related to previous and successor I- or110100 P-Frame Video Coding I-, P- and B-Frames I-Frame P-Frame I-Frame P-Frame B-Frames B-Frames B-Frames 110100 Video Coding I-, P- and B-Frames I P P I B-Frames B-Frames B-Frames 110100 Video Coding I-, P- and B-Frames I P P I B-Frames B-Frames B-Frames 110100 Video Coding Motion • Motion compensation – normative part of MPEG – Decoder’s point of view • Motion estimation – NOT normative part of MPEG – Encoder’s point of view 110100 Video Coding Motion Compensation • 1 motion vector for each region • region = macro block ∀⇒ 1 motion vector per macro block • Precision: 1 Pel, ½ Pel • motion vector coded differentially (prediction derived from preceding macro block) • Rules for resetting motion displacements 110100 Video Coding Motion Compensation • P-Pictures: – forward motion vectors • B-Pictures: – forward motion vectors – backward motion vectors – if both used: average of pel values from forward and backward motion-compensated reference picture 110100 Video Coding Motion Compensation • MPEG-2: – as in MPEG-1 (previous slide) – uses different names – Dual Prime Motion • for interlaced video • averaging predictions from two adjacent fields of opposite parity 110100 Video Coding Motion-Estimation I/P I/P 110100B Video Coding Motion-Estimation • Criterion for block matching – Mean Square Error – Mean Absolute Distortion 15 15 MAD(x,y) = (1/256)∑∑| Vn(x +i, y +i) −Vm(x + dx +i, y + dy + i) | i==0 j 0 – Sum of Absolute Distortions (SAD) – Minimization of the bitstream 110100 Video Coding Motion Estimation • Correlation between motion vectors 110100 Video Coding Motion Estimation • Motion displacement search algorithms – pel-recursive • iterative process • use intensity gradient and frame difference – block matching • compute measure of distortion • select vector that minimizes distortion 110100 Video Coding Motion Estimation • Fast search algorithm - sparse sampling • Variable resolution search techniques • Statistically sparse searches • Spatial continuity • Telescopic search • 3D spatial / temporal estimation • Phase correlation 110100 • othersVideo Coding ... Motion Estimation Overview in: Mitchell, Pennebaker, Fogg, and LeGall: MPEG Video Compression Standard, Chapman&Hall, 1996 p 301 ff. 110100 Video Coding Frame Order Display order I0B1B2P3B4B5P6B7B8I9... I0P3B1B2P6B4B5I9B7B8 … Coding order 110100 Video Coding MPEG data layout 110100 Video Coding MPEG Encoder Regulator Frame DCT Q VLC Buffer Re-order Motion - Multi- Estimator plex Q-1 Motion-Vectors DCT-1 + Modes Framestore and Predictor 110100 Video Coding MPEG Decoder Quantizer Stepsize Buffer MUX-1 Q-1 DCT-1 + Side Information Framestore and Predictor Motion-Vectors 110100 Video Coding MPEG TS • Packetised Elementary Stream (PES) • MPEG-2 Programme Stream MPEG-1 compatibility • MPEG-2 Transport Stream (TS) – fixed size 188 bytes packets • DSM-CC: Digital Storage Medium Command and Control • Service Information Tables – Information on streams, programmes, networks, conditional access, textual description, rating, ... 110100 Video Coding MPEG-2 TS 110100 Video Coding MPEG-2 Multiplexer 110100 Video Coding Presentation Unit Access Unit 110100 Video Coding PES 110100 Video Coding Programme Stream Multiplex • Pack Header – contains system clock reference – must occur every 0.7 sec.