Docsity

MPEG Data Extraction and Insertion Utility for Watermarking | ECE 9030, Papers of Electrical and Electronics Engineering

Partial preview of the text

Download MPEG Data Extraction and Insertion Utility for Watermarking | ECE 9030 and more Papers Electrical and Electronics Engineering in PDF only on Docsity!

MPEG Data Extraction and Insertion Utility for Watermarking

ECE9030 Research Assignment Author: Daniel Cross Professor: Dr. Bijan Mobasseri Date: 08/15/

  • Abstract
  • 1 Introduction
    • 1.1 Document Purpose.................................................................................................................................
    • 1.2 Document Layout
  • 2 Watermarking Overview
    • 2.1 Purpose of Watermarking
    • 2.2 Classification of Watermarks................................................................................................................
      • 2.2.1 Analog/Digital...............................................................................................................................
      • 2.2.2 Visibility
      • 2.2.3 Strength..........................................................................................................................................
    • 2.3 Digital Watermarking Domains............................................................................................................
      • 2.3.1 Spatial Domain Watermarking
      • 2.3.2 Transform Domain Watermarking
  • 3 Watermarking in MPEG Overview.....................................................
    • 3.1 MPEG Introduction
    • 3.2 Watermarking in MPEG......................................................................................................................
  • 4 mpegwm Utility Description
    • 4.1 Purpose of Utility
    • 4.2 Data Extraction
    • 4.3 Data Insertion.......................................................................................................................................
  • 5 The Future of the mpegwm Utility
    • 5.1 MPEG2 Support
    • 5.2 P and B frame Watermarking..............................................................................................................
    • 5.3 Support Alternate Scan Matrix
    • 5.4 Enhance User Input Options
    • 5.5 Automated Watermarking Within Utility...........................................................................................
  • 6 Appendix..............................................................................................
    • 6.1 A – Directions for using the Extraction and Insertion functionalities of mpegwm
    • 6.2 B – mpegwm Utility flow Diagram
    • 6.3 C – Sample Output of mpegwm Utility..............................................................................................
  • 7 Bibliography

1 Introduction

1.1 Document Purpose

This document will explain the purpose, use, background, and future of the MPEG Watermarking Extraction/Insertion utility (to be referred to henceforth in this document as “mpegwm”). An introduction to watermarking will be provided to assist the reader in understanding the purpose of the mpegwm utility. A brief overview of the MPEG standard as it applies to watermarking and this utility will also be provided (this overview is by no means an exhaustive MPEG dissertation 1 ). The purpose and use of the mpegwm utility will be discussed in great detail throughout this document. This paper will not, however, act as a README file for the utility. Appendix A contains a full README file that will provide the user with directions regarding the use of the tool. At the end of this document, future implementations of this tool are discussed. Some of the future implementations are already underway, and may (or may not) be implemented by the time the user reads this document. This document will be revised as the tool is updated.

1.2 Document Layout

This document has 7 major sections. The first section is an introduction to the document containing purpose and document layout sub-sections. The second section provides a watermarking overview. The second section covers the purpose of watermarking; watermarking classifications; and descriptions of spatial and transform domain watermarking methods. The third section discusses watermarking within the MPEG standard. It contains an MPEG overview and a description of watermarking in MPEG. The fourth section is a description of the mpegwm utility. It is split into utility purpose, data extraction, and data insertion sub-sections. If information on the functionality of the mpegwm utility is desired and no background MPEG and watermarking information is needed, then it is advisable to go directly to section four. Section five will provide information on the future of the mpegwm utility (what changes can be expected in later revisions). Section 6 is the Appendix. A README file for mpegwm and a descriptive process flow diagram are included in the Appendix. A sample of the utility’s output and input files along with some descriptions of the content of these files is also contained in the Appendix. Section 7 is the bibliography. The listings in this section are excellent sources for readers interested in learning more about MPEG standards, watermarking, or general video compression algorithms.

2 Watermarking Overview

2.1 Purpose of Watermarking

Traditionally, watermarking has been used to authenticate currency, documents, contracts, and other forms of hard-copy material in an attempt to prevent counterfeiting (^1) See “Coding of Moving Pictures and Associated Audio (MPEG1 and MPEG2)” (references 1 and 2)

and forgery. In more recent times, the analog television world took this idea a step further as many networks began adding visible logos to programming to establish ownership (and do a little self-promotion). In a digital environment, image/video watermarking involves embedding data into an image by modifying the image data in such a way that the perceptual effects are minimal. Presently, in the digital world, the idea of watermarking is being expanded to include Digital Rights Management. It is in the digital environment that much of the watermarking techniques are being developed. There are a number of applications that fit under the label of Digital Rights Management. Watermarking can be used to prevent unauthorized duplication of protected media or to keep tabs on the number of copies made for a particular media object. Watermarking can also be used to provide data integrity by resisting and/or detecting modifications to the original content. A type of watermarking technology known as fingerprinting can even provide information about the party responsible for giving copyrighted data away. Along with Digital Rights Management, watermarking technology can be used for some other interesting and useful applications. Search tags can be added as watermarks to assist multimedia search tools and to group the media object with others like it. Metadata for a particular object can be embedded into images of that object for efficient information storage and accessibility. Finally, watermarking can be used to hide covert correspondence in an overt data stream (a powerful technique in the world of espionage).

2.2 Classification of Watermarks

The mpegwm utility works as a tool to assist image watermarking efforts (henceforth, unless otherwise specified, all references to watermarking imply image watermarking only). Three categories must be considered when classifying different watermarking technologies. The list of these categories is as follows:

  1. Analog/Digital
  2. Visibility
  3. Strength The following sub-sections will provide a brief description for each of the three categories listed above. These three categories do not completely define a watermark, but instead, provide a basic description for some of the major attributes of the watermark.

2.2.1 Analog/Digital

The Analog/Digital category tells us whether the watermark is used in the analog environment or in the digital environment. If the watermark is used in the analog environment, it must be created using analog technology. If the watermark is used in the digital environment, it must be created using digital technology. The mpegwm utility is specifically designed to work with digital (MPEG) media so this document will deal exclusively with digital watermarking and related issues (henceforth, unless otherwise specified, all references to watermarking imply digital watermarking only).

2.2.2 Visibility

Visibility refers to the perceptual intent of the watermark. If the watermark is designed to be visible to the viewer after it is embedded in the data, then the watermark is said to be visible. If the watermark is designed to be transparent to the user (no

cannot regenerate the watermark. The person trying to verify whether or not the image is watermarked must have access to the original watermark. Although correlation receivers do not require a copy of the un-watermarked image (oblivious detection), they always require a copy of the original watermark itself^2. It can be shown that since the correlation detector uses statistical processes (correlation and a threshold value), there is always a chance for erroneous results using this method (lossy watermarking scheme). A good way to lower the chances of erroneous results is to spread each individual bit of the watermark out over many bits of the image to be watermarked. This spread-spectrum watermarking technique involves embedding 1 binary number into a block of pixels by altering the LSBs of these pixels according to a pseudorandom matrix if the binary value is a 1 and leaving the block unchanged if the binary value is a 0. The larger the block size, the more the energy of the watermark bit is spread among different pixels, and the better the chances for an accurate result from the correlation detector. The benefits of spatial domain watermarking are that it is easy to implement. This means that usually it can be done using simple algorithms. The algorithms for spatial domain watermarking usually are very fast and fragile. If you want fragile watermarking, then this can be an asset. A downside of spatial domain watermarking is that it is easier for an attacker to compromise than transform domain watermarking. Another problem is that spatial domain watermarking is more susceptible to noise. Noise susceptibility is a big issue since most images are compressed after the watermark is embedded, causing some of the watermark to be lost. Another problem with this technique is the drastic perceptual impact of the watermark when using indexed images with small color maps (see problem 2 in this sub-section above).

2.3.2 Transform Domain Watermarking

Transform domain watermarking addresses some of the issues associated with spatial domain watermarking. Watermarks in the transform domain are much more robust than in the spatial domain. Transform domain watermarking is less susceptible to noise, and attacks. Transform domain watermarking involves watermarking the frequency coefficients that are created by transforming the spatial domain pixel values of an image to frequency coefficients. There are three different types of transforms used to create these frequency coefficients. The Discrete Fourier Transform(DFT) is a symmetric transform capable of picking out the spatial frequency power distribution from an image. The Discrete Cosine Transform(DCT) provides the same functionality as the DFT but does not require the overhead associated with symmetry and is easier to implement in software than the DFT. The Discrete Wavelet Transform(DWT) is like a DFT over a short window of time that moves along the time axis and changes in duration. The DWT also pulls frequency components out of the image data. Of the three of these transform methods, only the DCT is used in the MPEG1 and MPEG2 standards. Since the mpegwm utility is specifically designed to work within these standards, only watermarking in the DCT transform domain will be discussed here.^3 (^2) For more information on Oblivious detection using Correlation Detectors see “Digital Watermarking” slides (reference 4) (^3) For more information on DFT, DCT, and DWT transforms see “Image and Video Compression for Multimedia Engineering” (reference 8)

DCT domain watermarking, involves slightly modifying DCT coefficients in the transform domain. By doing this, the energy of each binary value of the watermark is spread into every pixel of the image. Once the inverse transform is executed, it is not possible to find the watermark in the spatial domain. This makes the watermark less susceptible to attacks. Selection of DCT coefficients for watermarking is an important task. The more perceptually significant coefficients (greater magnitudes) are the candidates for watermarking, since the watermark value (which is just noise to the image) would have less of an impact on a larger magnitude. Since we are dealing with the MPEG standard (which encodes key frames through the JPEG algorithm), it is important to note that the quantization tables used in MPEG (as well as JPEG) quantize and often completely remove (in an attempt to compress the image) many of the high-frequency values in the block being processed. This would indicate that the user should place watermarks in the low-frequency DCT coefficients. Another problem, however, is that a tremendous amount of the image data is compacted into the low-frequency coefficients. This means that altering these values may have serious perceptual impact on the image. Given these two competing issues, the most desirable place to watermark in MPEG (as well as JPEG) is the middle coefficients if watermarking is to occur prior to compression. Embedding a watermark into an image prior to compression is an extremely tricky task. No matter how well the coefficients are chosen, the watermark will inevitably become corrupted when quantization removes a large number of the coefficients completely from the transform block. At this point we could use a correlation detector (see section 2.3.1) to determine whether a watermark is present or not. In the end, the DCT domain watermarking scheme described above (as well as DFT and DWT) is just as lossy a watermarking scheme (and, if highly compressed, more lossy) than spatial domain watermarking. The next question becomes “how can a watermark in an MPEG (or JPEG) image be robust enough to withstand compression 100% of the time?”. The simple truth is that it cannot. The only way to overcome the data loss due to compression in the DCT transform domain is to embed the watermark after compression has already taken place. The upside is obvious; we no longer have to worry about losing watermark data due to compression algorithms. The downside is that after compression, there are not many coefficients left to watermark (fewer coefficients means fewer watermark bits per image). Also, most of the redundancy within the image has already been removed. The chance of impacting the image by altering the remaining values is much higher. There are some applications which absolutely require that the watermark be completely in tact when the watermarked file reaches its destination (namely, any technique that does not have the original watermark at its disposal or needs to receive every watermark bit accurately). The mpegwm utility is specifically designed for just such a watermarking application.

3 Watermarking in MPEG Overview

3.1 MPEG Introduction

The mpegwm utility is designed to work with MPEG video files. It is important to go into a little more detail regarding MPEG watermarking to provide some insight as

3.2 Watermarking in MPEG

As discussed in section 2, the mpegwm utility is intended only for watermarking applications that adhere to the following classifications:

  1. Digital (MPEG)
  2. invisible
  3. robust
  4. post-compression
  5. transform domain The watermarking method described in this section adheres to the above classifications. There are other ways to watermark an MPEG stream that are not mentioned here. In the future, the mpegwm utility may support alternative watermarking methods (section 5). The watermarking method described here is for the MPEG standard only. The watermarking method described here is invisible. The watermark is to have minimal impact on the visual presentation of the MPEG stream. This watermarking method is robust. The intent is to create a watermark that can be extracted with bit-for-bit accuracy from the watermarked MPEG file by taking the difference between the watermarked file and the original file. The way to accomplish this is to watermark in the post-compression domain. This way, no data can be lost due to quantization. Since this watermarking technique deals with video streams that are already configured as MPEG, the streams to be watermarked are already compressed. Watermarking MPEG streams is watermarking in the post-compression domain. The watermarking scenario described below is only for watermarking transform coefficients in I frames. The mpegwm utility only supports this type of watermarking application at this time (changes to implement P and B frame motion vector watermarking are currently under way…see section 5.2). The first step in the watermarking process is to parse the Sequence header (the first layer in the stream), pulling out and saving data as necessary. The Sequence header and its associated extensions contain information regarding the frame dimensions and aspect ratio. The frame and bit rates are also contained in this section of the stream. If alternate quantizer matrices are supplied by the stream, they would also be contained here. The color format and progressive/interlaced indicator is also in the stream here if MPEG2 is used. The video format (PAL, NTSC, MAC, etc.) is also in this portion of the stream. The next step is to parse the Group of Pictures Header and extract any necessary data. This is the second layer of the stream. Timing information that could be useful if working with 29.97Hz. frame rate is contained in this portion of the stream. Information in this section is not usually crucial to the watermarking utilities that will be working within the stream. The Picture header and its associated extensions are the third layer of the stream. Parsing this layer provides crucial information for the watermarking utilities. The picture type (I, P, or B frame) can be determined from the stream at this layer. The alternate scan indicator is set here. It tells the decoder whether the standard scan matrix is used to re- arrange the Huffman encoded values or if an alternate matrix is used. The fourth layer of the MPEG standard consists of the Slice header. Information regarding the individual slices that make up a picture is contained here. Parsing this layer can provide the location in the frame of a particular slice. This can be useful when watermarking only particular spatial regions of the frames.

The fifth layer of the MPEG standard consists of the Macroblock data. Parsing this layer will provide the location in the Slice for each macroblock. The motion vectors used for motion prediction in P and B frames is stored in this portion of the stream. The Block data constitutes the sixth and final layer of the MPEG protocol. When watermarking I frames, the actual DCT luminance and chrominance values can be pulled out of the stream at this point. The picture type information provided by the Picture header would be used to determine whether the frame is an I frame or not. If it is an I frame, then the luminance and chrominance values could be extracted at this point and altered (slightly) to embed the watermark bits in the DCT coefficients. Once the watermark bits are embedded, the luminance and chrominance values could be re- inserted into the stream. The resulting stream would be a watermarked version of the original MPEG video. The values extracted from the Sequence, GOP, Picture, and Slice layers of the protocol can be used to control how strong the watermark can be and where exactly to place it in the video sequence.^5

4 mpegwm Utility Description

4.1 Purpose of Utility

The mpegwm utility extracts the DCPM-encoded DC and signed Huffman- encoded AC DCT levels (associated with but not the same as DCT coefficients) from the I frames of an MPEG1 stream and re-inserts these levels back into the stream after they have been watermarked. The mpegwm utility does not currently support MPEG streams, but a new version of this executable is on the way that is fully compliant with MPEG2 as well as MPEG1 standards (see section 5.1). This utility does not actually watermark the MPEG stream, but instead, acts as a tool to extract and re-insert the watermark candidate data in a simple, automated fashion. The user is expected to watermark the candidate data using some other tool or by hand. The data extraction and insertion is done by the same executable. Input parameters determine what course of action the utility will take.

4.2 Data Extraction

When candidate data is to be extracted from an MPEG stream, an appropriate MPEG input file (file to be watermarked) must exist in a directory where the utility can access it (often times it is placed in the same directory as the utility). The utility is to be run from a DOS command window (if run on PC) or Unix command window (if run on a SUN). The user indicates that the utility is to be run in extract mode (see appendix A for command line argument description). The user indicates the frame or range of frames to be considered as candidates for watermarking (see Appendix A for command line argument description). Only I frames are considered for watermarking in this version of the utility, but future versions will include P and B frames (see section 5.2). It is important for the user to remember what (^5) The text does not include all values contained in the stream at the various layers. It only includes those values that are potentially useful to the MPEG watermarking process. For all values contained in the MPEG stream, see “Coding of Moving Pictures and Associated Audio (MPEG1 and MPEG2) (references 1 and 2)

The mpegwm utility outputs a parameters.par file as well as the output files for each frame. The parameters.par file includes important data that the user will need when attempting to watermark the frames. This data includes frame dimensions; aspect ratio; frame rate; bit rate; I, P, and B frame position; frame macroblock width; frame macroblock height; and total macroblocks in frame.^6

4.3 Data Insertion

When watermarked data is to be re-inserted into an MPEG stream, the appropriate watermarked frame files must exist in a directory where the utility can access them (often times they are placed in the same directory as the utility). The utility is to be run from a DOS command window (if run on PC) or Unix command window (if run on a SUN). The user indicates that the utility is to be run in insert mode (see appendix A for command line argument description). The user indicates the frame or range of frames to be re-inserted into the stream (see Appendix A for command line argument description). It is very important that the frames are inserted into their proper positions within the stream, so the user must make sure the range of frames is correct before running the utility. When the utility runs, it will follow the flow of events indicated in the mpegwm Utility Flow Diagram (see Appendix B). It will open the original MPEG file from which the frames were extracted. Then a new MPEG file called “watermark.mpeg” will be opened. This new file will contain the merge of the original MPEG file with the new watermarked frames, and become a watermarked version of the original file. The original MPEG file remains in tact and un-watermarked. The user can then compare the watermarked file with the original MPEG file. The Sequence, GOP, Picture, Slice, and macroblock information is parsed in the same way that they are parsed in the extraction phase of this process - except for one difference. In the insertion phase, every bit that gets parsed in these layers is copied out to the “watermark.mpeg” file so that it can be a duplicate of the original file up to the actual block data. When the utility gets to the Block layer, the insert phase diverges from the extract phase. The utility begins to parse the first block of the macroblock in the original MPEG file. If the frame that the macroblock is part of is not an I frame within the user-specified range, the block is copied to the “watermark.mpeg” file without any changes. Otherwise, the original block is replaced by the watermarked block and inserted into the “watermark.mpeg” file. If the block is to be replaced, then the utility makes sure that the input file containing the block is open and the input pointer is pointing to the DC component of the current watermarked 8x8 block. This file is left open until the frame is completely finished processing. All blocks in the watermarked frame (Y, Cb, and Cr) will replace their original counterparts whether these blocks are watermarked or not (i.e. if only one 8x8 Cb block is watermarked in frame 20, all Cb, Y, and Cr blocks for frame 20 must be in the proper input files and ready for insertion). The input files must follow the naming convention stated here: WDCTframe#Y = watermarked Luminance(Y) frame number # WDCTframe#U = watermarked Chrominance(Cb) frame number # WDCTframe#V = watermarked Chrominance(Cr) frame number # (^6) See Appendix C for a sample output from the mpegwm utility extraction phase.

Each watermarked frame for insertion must have three files associated with it for each of the three color components Y, Cb, and Cr. Once the appropriate file is open and ready to be read, the entire 8x8 block is read into an array. The values are scanned to put them in standard MPEG stream order (streams using the alternate scan matrix are not currently supported, but should be in a future implementation…see section 5.3). The DC value is DCPM encoded and inserted into “watermark.mpeg”. After the DC coefficient is processed, all AC coefficients for the 8x8 block are processed. The zero run for each non-zero AC coefficient is determined. The signed AC level and its zero run value are Huffman encoded and inserted into “watermark.mpeg”. Once all of the blocks in the macroblock are processed, a new macroblock is processed in the same way. Once all of the macroblocks are processed, a new slice is processed. Since the watermarked values can differ in bit-length with their non- watermarked counterparts, the Slice headers can be shifted out of byte-alignment. In order to prevent this from happening, the utility automatically inserts as many 0s (into the “watermark.mpeg” file) as is necessary to bring the next Slice header into byte- alignment. Then the next slice is processed in the same way as the previous slice. When all of the slices are processed, the frame is completely processed. The Y, Cb, and Cr input files associated with the frame are closed and a new set of input files is opened for the next frame to be parsed (if the frame is part of the user-specified range). This process will continue until all frames are parsed. At this point, the insert phase of the utility is complete. There will be a “watermark.mpeg” file in the same directory as the mpegwm utility. This file is the watermarked version of the original MPEG file. 7

5 The Future of the mpegwm Utility

The following is a list of future features of the mpegwm utility. At this time availability dates are not defined, but the sections are listed in order of priority. The first section is the highest priority, and so will be attempted prior to moving on to the next section.

5.1 MPEG2 Support

The current version of the mpegwm utility only supports MPEG1. The first upgrade to be made will support processing MPEG2 as well as MPEG1 video streams. Since this utility is built on top of an MPEG decoder (originally authored by The MPEG Software Simulation Group 8 ) that supports MPEG1 and MPEG2 standards, the task of adding support for MPEG2 should be minimal.

5.2 P and B frame Watermarking

The current version of the mpegwm utility only supports extraction and insertion of I frame transform coefficients (signed magnitudes). Work has begun to support extraction of P and B frame prediction error values for the purpose of watermarking. The changes required will involve (among other things) outputting separate files for P and B frames during extraction; inputting separate P and B files during insertion; and changing (^7) See Appendix C for a sample output from the mpegwm utility insertion phase. (^8) For more information on this Cod/Dec see “MPEG Cod/Dec” Source Code (reference 5)

6 Appendix

6.1 A – Directions for using the Extraction and Insertion

functionalities of mpegwm

Extracting I frames: steps

  1. open a command window and go to the directory that contains mpegwm.exe
  2. type the following at the command line: -b -z ext where start is the number of the first I frame to extract and stop is the number of the last I frame to extract The numbers for the start/stop range start at 1 and do not take P or B frames into account. Example: for this sequence (IPBIPBIPB), to take all I frames in this sequence the user would use start number of 1 and stop number of 3. When re-inserting these watermarked frames, the user need only use a subset of the range of frames that were initially extracted. So in the above example, the user could re-insert I frames (1 2 3) or (1 2) or (2 3) or (1) or (2) or (3). output
  3. DCTframe#Y - The luminance(Y) blocks including DC signed levels, AC signed levels, and zeros. The values of the AC coefficients are signed Huffman levels according to table B- or B-15 of the MPEG1/2 specifications.
  4. DCTframe#U - The chrominance(Cb) blocks including DC signed levels, AC signed levels, and zeros. The values of the AC coefficients are signed Huffman levels according to table B- or B-15 of the MPEG1/2 specifications.
  5. DCTframe#V - The chrominance(Cr) blocks including DC signed levels, AC signed levels, and zeros. The values of the AC coefficients are signed Huffman levels according to table B- or B-15 of the MPEG1/2 specifications. where # is the number of the I frame
  6. Parameters.par - File containing information about the MPEG file that was used for the extraction. This file contains total number of macroblocks per frame, frame width, frame height, etc. Inserting I frames: steps
  7. open a command window and go to the directory that contains mpegwm.exe make sure that the WDCTframe#Y, WDCTframe#U, and WDCTframe#V files are in this directory.
  8. type the following at the command line: -b -z ins where start is the number of the first I frame to extract

and stop is the number of the last I frame to extract The numbers for the start/stop range start at 1 and do not take P or B frames into account. Example: for this sequence (IPBIPBIPB), to insert all I frames in this sequence the user would use start number of 1 and stop number of 3. When re-inserting these watermarked frames, the user need only use a subset of the range of frames that were initially extracted. So in the above example, the user could re-insert I frames (1 2 3) or (1 2) or (2 3) or (1) or (2) or (3). output

  1. watermark.mpeg This file is a combination of the original file (for any frame not inserted) and the watermarked frames (user-defined range of watermarked I frames). This is the watermarked mpeg file. NOTES
  2. This application only supports MPEG1 at this time.

Yes Yes Yes No No No Yes Yes No No Get GOP header and write to to OUTPUT.mpeg GOP() Next GOP ? Picture() Get Macroblock data and write to to OUTPUT.mpeg Macroblock() Next Macro block? Block() Get Sequence header and write to to OUTPUT.mpeg Sequence() Next Sequence ? GOP() Get Picture header and write to to OUTPUT.mpeg Picture() Next Picture ? Slice() Get Slice header and write to to OUTPUT.mpeg Slice() Next Slice ? Macroblock() RETURN RETURN RETURN RETURN RETURN

No Yes 0 1 Yes No Block() Get next Block Write all block data directly to OUTPUT.mpeg I frame & In range? Flag value? Extract() Insert() Next Block in Macro? RETURN