This example demonstrates video decoding using the rocDecode library's built-in bitstream reader instead of FFMPEG demuxer. The sample reads raw video bitstreams directly and decodes them using hardware acceleration, providing an alternative to FFMPEG-based demuxing. This approach is useful for scenarios where FFMPEG is not available or when working with raw elementary streams.
- Parse command-line arguments for input file, device ID, and output options.
- Create the built-in bitstream reader using
rocDecCreateBitstreamReader(). - Extract codec information from the bitstream.
- Create the video decoder instance with the detected codec.
- Verify codec support on the selected GPU device.
- Loop through bitstream:
- Read video data packets using the bitstream reader.
- Parse packets using the video parser.
- Decode frames through parser callbacks.
- Retrieve decoded frames.
- Optionally save frames to output file.
- Display decoding statistics.
- Destroy bitstream reader and clean up decoder resources.
-
Built-in Bitstream Reader: rocDecode provides a native bitstream reader:
rocDecCreateBitstreamReader(): Creates a reader for raw elementary streams.rocDecDestroyBitstreamReader(): Releases bitstream reader resources.- Eliminates dependency on FFMPEG for simple decode scenarios.
- Supports common video codecs (H.264, HEVC, VP9, AV1).
-
Raw Elementary Stream Processing: The bitstream reader handles:
- Direct reading of compressed video data.
- Automatic detection of codec type from bitstream.
- Extraction of sequence parameters and frame data.
- No container format parsing required.
-
Decoder Integration: The decoder works with the bitstream reader:
rocDecCreateDecoder(): Initializes decoder with codec from bitstream.rocDecParseVideoData(): Parses data provided by bitstream reader.rocDecDecodeFrame(): Decodes frames using hardware acceleration.- Same decode pipeline as FFMPEG-based samples.
-
Use Cases:
- Decoding raw elementary streams without container formats.
- Embedded systems where FFMPEG is not available.
- Custom video processing pipelines.
- Testing decoder with raw bitstream data.
- Scenarios requiring minimal dependencies.
-
Limitations:
- Only supports elementary streams (no container formats like MP4, MKV).
- Limited metadata extraction compared to FFMPEG.
- No support for multiplexed audio/video streams.
- Codec must be detectable from bitstream headers.
rocDecCreateDecoderrocDecDecodeFramerocDecGetVideoFramerocDecGetDecodeStatusrocDecDestroyDecoderrocDecCreateVideoParserrocDecParseVideoDatarocDecDestroyVideoParserrocDecCreateBitstreamReaderrocDecDestroyBitstreamReaderrocDecGetErrorName
hipSetDevicehipGetDevicePropertieshipMallochipFreehipMemcpyhipMemcpyDtoH
rocDecDecoderHandleRocdecVideoParserrocDecVideoCodecrocDecVideoSurfaceFormatrocDecVideoChromaFormatrocDecDecoderCreateInfoRocdecParserParamsRocdecVideoFormatRocdecPicParamsRocdecParserDispInforocDecDecodeStatus