Perform HW-accelerated decoding with output frames from HW video surfaces.
/*
* Copyright (c) 2017 Jun Zhao
* Copyright (c) 2017 Kaixuan Liu
*
* HW Acceleration API (video decoding) decode sample
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file HW-accelerated decoding API usage.example
* @example hw_decode.c
*
* Perform HW-accelerated decoding with output frames from HW video
* surfaces.
*/
#include <stdio.h>
{
int err = 0;
fprintf(stderr, "Failed to create specified HW device.\n");
return err;
}
return err;
}
{
}
fprintf(stderr, "Failed to get HW surface format.\n");
}
{
fprintf(stderr, "Error during decoding\n");
}
while (1) {
fprintf(stderr, "Can not alloc frame\n");
}
return 0;
fprintf(stderr, "Error while decoding\n");
}
/* retrieve data from GPU to CPU */
fprintf(stderr, "Error transferring the data to system memory\n");
}
tmp_frame = sw_frame;
} else
fprintf(stderr, "Can not alloc buffer\n");
}
(
const uint8_t *
const *)tmp_frame->
data,
fprintf(stderr, "Can not copy image to buffer\n");
}
fprintf(stderr, "Failed to dump raw data.\n");
}
}
}
int main(
int argc,
char *argv[])
{
if (argc < 4) {
fprintf(stderr, "Usage: %s <device type> <input file> <output file>\n", argv[0]);
return -1;
}
fprintf(stderr, "Device type %s is not supported.\n", argv[1]);
fprintf(stderr, "Available device types:");
fprintf(stderr, "\n");
return -1;
}
if (!packet) {
fprintf(stderr, "Failed to allocate AVPacket\n");
return -1;
}
/* open the input file */
fprintf(stderr, "Cannot open input file '%s'\n", argv[2]);
return -1;
}
fprintf(stderr, "Cannot find input stream information.\n");
return -1;
}
/* find the video stream information */
fprintf(stderr, "Cannot find a video stream in the input file\n");
return -1;
}
fprintf(stderr, "Decoder %s does not support device type %s.\n",
return -1;
}
break;
}
}
return -1;
return -1;
fprintf(stderr,
"Failed to open codec for stream #%u\n",
video_stream);
return -1;
}
/* open the file to dump raw data */
/* actual decoding and dump the raw data */
break;
}
/* flush the decoder */
return 0;
}