Decoding method for solving overtime memory overflow

By using the FFMPEG soft decoding library to obtain and process video frame information under the Linux system, the memory leakage problem caused by wrong frames during the decoding process of the Atlas 200 AI chip is solved, and the integrity and efficiency of video decoding are achieved.

CN119520792AActive Publication Date: 2025-02-25TIANJIN JINHANG COMP TECH RES INST
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411599695.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-25
Estimated Expiration
2044-11-11

AI Technical Summary

Technical Problem

Under the Linux system, the Atlas 200AI chip does not release memory due to error frames during the decoding process, and cannot complete the decoding process, and cannot effectively extract image information with parameter frames.

Method used

The FFMPEG soft decoding library is used to obtain compressed frame parameter information and image information, form a decoded data packet and transmit it to the Atlas 200AI chip, and avoid memory leakage by monitoring the hardware decoding time and resource scheduling.

Benefits of technology

It effectively solves the memory leakage problem caused by wrong frames of hard decoding, realizes the integrity and efficiency of video decoding, and extracts image information with parameter frames.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The invention discloses a decoding method for solving overtime memory overflow. The decoding method comprises the following steps: S1, transplanting ffmpeg to an acceleration module platform; s2, setting an initialization resource calling interface; s3, using an ffmpeg dynamic library to obtain a complete compressed image data packet containing a parameter frame; s4, performing hard decoding based on an acceleration module; s5, setting an error callback function to check a decoding state; s6, returning the decoded image to the upper application through an interface function; and S7, releasing decoding channel resources. A soft decoding method is adopted to form a complete data packet containing an image frame and a parameter frame, and then a hard decoding module of a chip is used to complete the decoding process, so that the decoding time is effectively shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of video decoding technology under Linux system. In the application scenario where the system is Linux, a decoding method based on an acceleration module to solve the timeout memory overflow is designed and implemented under Linux system according to the characteristics of atlas200AI chip and combined with hardware attributes and soft decoding characteristics. The present invention is that the system is Linux, firstly, the FFMPEG soft decoding library is used to perform data analysis on the data received by the network, and the compressed frame parameter information and image information are effectively obtained, and the decodable data packet is transmitted to the atlas200AI chip, and the hardware decoding time and resource scheduling are monitored at the same time, so as to avoid the problem that the hard decoding cannot complete the decoding process due to the memory not being released due to the error frame in the decoding process. Background Art

[0002] The Atlas 200AI acceleration module integrates the Ascend 310AI processor, which can realize image recognition, image classification, etc. on the edge. It can realize various data analysis and reasoning calculations such as images and videos, and is widely used in edge AI scenarios such as smart cameras, robots, and drones.

[0003] However, Atlas 200AI belongs to the category of hard decoding. When the protocol frame does not fully comply with the decoding protocol, or there are many error frames, the decoding efficiency is relatively low or cannot be decoded, and for image information with parameter frames, the hard decoding module cannot extract parameter information. The present invention uses the ffmpeg decoding library to obtain the parameter frame information and data frame information in the original frame, obtains the complete image frame data packet, transmits the decodable complete data packet to the hard decoding module, completes the decoding function, and at the same time, in order to solve the call interface for the upper-layer application, it is provided to the upper layer in the form of a dynamic library. In addition, in order to avoid the hardware from being unable to release memory resources due to decoding timeout caused by error frames, monitoring means are used to release memory in time to avoid memory leakage. Summary of the invention

[0004] (I) Purpose of the invention

[0005] The purpose of the present invention is to provide a decoding method for solving timeout memory overflow, adopting a soft-hard combination decoding method based on an acceleration module to solve the video decoding problem under a Linux system.

[0006] (II) Technical solution

[0007] In order to solve the above technical problems, the present invention provides a decoding method for solving timeout memory overflow, which comprises the following steps:

[0008] S1: port ffmpeg to the acceleration module platform;

[0009] S2: Set up the initialization resource calling interface;

[0010] S3: Use the ffmpeg dynamic library to obtain the complete compressed image data packet containing the parameter frame;

[0011] S4: hard decoding based on the acceleration module;

[0012] S5: Set the error callback function to check the decoding status;

[0013] S6: Return the decoded image to the upper layer application through the interface function;

[0014] S7: Release the decoding channel resources.

[0015] Wherein, step S1 includes the following process:

[0016] S11: Configure ffmpeg compilation properties, and configure parameters according to platform type, cpu type, codec properties, format conversion properties, and cross-compilation properties;

[0017] S12: Modify the acodec.h file, add the parameter frame length sei_len and array sei_buf, and determine its parameter frame size SEI_BUF_SIZE according to the application layer requirements;

[0018] S13: Add the function of obtaining the parameter frame in the decode_nal_sei_prefix function in the hevc_sei.c file: obtain the parameter size in the function, assign size to sei_len, determine whether size is less than or equal to SEI_BUF_SIZE, and if the condition is met, copy the data in the context parameter array gb to sei_buf, the length of the copy is size, and the array subscript i of the copied sei_buf is the index index of the gb array divided by 8, that is, sei_buf[i]=gb_buf[index / 8];

[0019] S14: Execute the configure command to generate decoding libraries libavcodec, libavformat, libavutil, and libswscale in the subfolder lib of the configuration folder;

[0020] S15: Copy the dynamic library to the / usr / lib path of the decoding board.

[0021] Among them, in step S2, the calling interface is set as an external function, the parameters and return values ​​are set according to the protocol, and the decoding resources are initialized.

[0022] Wherein, step S2 includes the following process:

[0023] S21: Initialize semaphore mutex;

[0024] S22: Create an initialization resource setting thread, and the main logic content of the thread is set as follows:

[0025] S221: Setting the hardware decoding device serial number;

[0026] S222: Use library functions to create a hard decoding context environment;

[0027] S223: Use library functions to create a hard-decoded data stream object;

[0028] S224: Create a decoding thread;

[0029] S225: Initialize ffmpeg resources;

[0030] S226: Create a network data receiving thread and put the received data into a ring buffer array;

[0031] S227: Initialize the accelerated decoding module resources. The process is as follows:

[0032] S2271: Create decoding channel attributes. If the creation is successful, proceed to the next step, otherwise exit with an error;

[0033] S2272: Set the decoding channel ID number. If the setting is successful, proceed to the next step, otherwise an error is reported and exit;

[0034] S2273: Set the decoding thread number;

[0035] S2274: Set the decoding channel callback function. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0036] S2275: Set the decoding channel error exception callback function. If the setting is successful, proceed to the next step, otherwise report an error and exit;

[0037] S2276: Set the decoding type of the decoding channel. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0038] S2277: Set the output image format of the decoding channel. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0039] S2278: Set the decoding channel output mode. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0040] S2279: Create a decoding channel according to the decoding channel attributes;

[0041] S228: Periodically query whether the network has received the image array, that is, whether the ring buffer array has data. If so, take the data according to the frame length specified by the protocol and proceed to the next process. Otherwise, continue to query and wait for network data.

[0042] Wherein, step S3 includes the following process:

[0043] S31: Initialize the decoding library usage environment

[0044] First, set the decoder type and use the HEVC / h265 type decoder; then initialize the decoder context and dynamically apply for image frame storage space;

[0045] S32: Create ffmpeg to obtain data packets thread, the creation process is as follows:

[0046] S321: Get the first address pointer bufPtr and length bufLen of the image data array read from the network;

[0047] S322: Determine whether the current data length bufLen is greater than 0, if so, proceed to the next step, if not, wait for the network to send data next time;

[0048] S323: Send the data array first address pointer bufPtr and length bufLen to the soft decoding module, and use the library function av_parser_parse2 to split the data into frames. If a complete image frame data packet can be successfully obtained from the array, it will be recorded and continue to the next step. If not, the decoding process will be exited.

[0049] S324: Save the length ret of the data packet of the image frame segmentation in the data array this time, remove the length ret of the data packet of the image frame segmentation this time from the total length bufLen of the data array, and move the first address pointer bufPtr forward by the number of times ret;

[0050] S325: Put the complete data packet of the image segmented this time into a queue to be decoded.

[0051] Among them, in step S4, the complete data packet filtered by ffmpeg is hard-decoded, and the hard decoding process is as follows:

[0052] S41: Set the decoding callback function. The process is as follows:

[0053] S411: Use the library function to obtain the normal frame output of the decoding. If the obtained result is 0, execute the next step, otherwise report an error and exit;

[0054] S412: using library functions to obtain image attribute data output;

[0055] S413: Use library functions to obtain image size, width and height parameter data from output;

[0056] S414: copy the image data and parameter data to the user return array g_send_buf;

[0057] S415: Unlock the semaphore mutex and allow access to the user return array g_send_buf;

[0058] S42: Obtaining a complete image data packet from the decoding queue in step S3;

[0059] S43: Send the data packet to the hard decoding module for decoding. The process is as follows:

[0060] S431: Using library functions to dynamically apply for image storage space;

[0061] S432: Obtaining parameter information of the image frame from ffmpeg;

[0062] S433: Integrate the parameter information and the decoded image data into a complete frame;

[0063] S434: Create an input image stream attribute object;

[0064] S435: Set the input image stream attribute object;

[0065] S436: Dynamically apply for image output memory space;

[0066] S437: Create an output image attribute object;

[0067] S438: Setting output image attributes according to image data, size, and format;

[0068] S439: using the decoding channel attribute, the input image stream attribute, and the output image attribute as parameters and using a library function to send the image frame data to the hard decoding module;

[0069] S4310: Release the requested image memory space;

[0070] S4311: Destroy the input image stream object resources.

[0071] In step S5, during the decoding process, it is checked in real time whether the decoded image frame can be decoded smoothly. If not, resources need to be released. Step S5 includes the following process:

[0072] S51: Set the error callback function to callbackErr, and the parameter is the exception type object pointer;

[0073] S52: using a library function to obtain the decoding task number taskid in the abnormal situation information;

[0074] S53: Obtain the image frame number frameid of the decoded stream in the abnormal situation information;

[0075] S54: Obtaining the device number in the abnormal situation decoding device;

[0076] S55: Check whether the device id and task id in the previous initialization settings are consistent. If yes, use the memory space applied for in S4 using the image frame number frameid.

[0077] Among them, in step S6, after obtaining the hard-decoded image, the image data is returned through the interface function, and the process is as follows:

[0078] S61: Set the readbuf function to provide an interface for obtaining image data. The process is as follows:

[0079] S611: The semaphore is locked to prevent read and write conflicts in the user return array;

[0080] S612: copy the decoded image data array g_send_buf in step 4 to the temporary data array g_read_buf;

[0081] S613: Return the image data length;

[0082] S62: Set and provide a function void*getbufAddress for obtaining the address of the image data array, which returns the address of g_read_buf.

[0083] The process of step S7 is as follows:

[0084] S71: calling a library function to report the decoding thread ID and data stream ID described;

[0085] S72: Set the flag of the decoding thread to false;

[0086] S73: Release the decoding thread;

[0087] S74: Destroy the decoding channel object;

[0088] S75: Set the decoding channel description pointer to null;

[0089] S76: Destroy the decoding stream description object;

[0090] S77: Destroy the decoding stream object;

[0091] S78: Set the array object in the decoded stream to empty.

[0092] (III) Beneficial effects

[0093] The decoding method for solving the timeout memory overflow provided by the above technical solution can realize the video decoding and transmission problem under the Linux system. The method has been verified by the algorithm and experimentally tested. The results show that the solution can solve the image decoding problem by using the soft decoding method to form a complete data packet containing image frames and parameter frames, and then use the chip's hard decoding module to complete the decoding process, effectively reducing the decoding time. In addition, the hard decoding status is monitored in real time, and resources are released in time for undecodable error frames to prevent memory leakage. DETAILED DESCRIPTION

[0094] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with embodiments.

[0095] The decoding method for solving the timeout memory overflow in this embodiment includes the following steps:

[0096] S1: Porting ffmpeg to the acceleration module platform

[0097] S11: Configure ffmpeg compilation properties, and configure parameters according to platform type, CPU type, codec properties, format conversion properties, and cross-compilation properties.

[0098] S12: Modify the acodec.h file, add the parameter frame length sei_len and array sei_buf, and determine its parameter frame size SEI_BUF_SIZE according to the application layer requirements;

[0099] S13: Add the function of obtaining the parameter frame in the decode_nal_sei_prefix function in the hevc_sei.c file: obtain the parameter size in the function, assign size to sei_len, determine whether size is less than or equal to SEI_BUF_SIZE, and if the condition is met, copy the data in the context parameter array gb to sei_buf, the length of the copy is size, and the array subscript i of the copied sei_buf is the index index of the gb array divided by 8, that is, sei_buf[i]=gb_buf[index / 8];

[0100] S14: Execute the configure command to generate decoding libraries libavcodec, libavformat, libavutil, and libswscale in the subfolder lib of the configuration folder.

[0101] S15: Copy the dynamic library to the / usr / lib path of the decoding board;

[0102] S2: Set up the initialization resource call interface

[0103] Set the calling interface to an external function, set the parameters and return values ​​according to the protocol, and initialize the decoding resources. The specific operations are as follows:

[0104] S21: Initialize semaphore mutex;

[0105] S22: Create an initialization resource setting thread. The main logic content of the thread is as follows:

[0106] S221: Setting the hardware decoding device serial number;

[0107] S222: Use library functions to create a hard decoding context environment;

[0108] S223: Use library functions to create a hard-decoded data stream object;

[0109] S224: Create a decoding thread;

[0110] S225: Initialize ffmpeg resources;

[0111] S226: Create a network data receiving thread and put the received data into a ring buffer array;

[0112] S227: Initialize the accelerated decoding module resources. The specific operations are as follows:

[0113] S2271: Create decoding channel attributes. If the creation is successful, proceed to the next step, otherwise exit with an error;

[0114] S2272: Set the decoding channel ID number. If the setting is successful, proceed to the next step, otherwise an error is reported and exit;

[0115] S2273: Set the decoding thread number;

[0116] S2274: Set the decoding channel callback function. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0117] S2275: Set the decoding channel error exception callback function. If the setting is successful, proceed to the next step, otherwise report an error and exit;

[0118] S2276: Set the decoding type of the decoding channel. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0119] S2277: Set the output image format of the decoding channel. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0120] S2278: Set the decoding channel output mode. If the setting is successful, proceed to the next step, otherwise exit with an error;

[0121] S2279: Create a decoding channel according to the decoding channel attributes;

[0122] S228: Regularly query whether the network has received the image array, that is, whether the ring buffer array has data. If yes, take the data according to the frame length specified by the protocol and proceed to the next process. Otherwise, continue to query and wait for network data.

[0123] S3: Use ffmpeg dynamic library to obtain complete compressed image data packets including parameter frames

[0124] S31: Initialize the decoding library usage environment

[0125] First, set the decoder type and use the HEVC (h265) decoder. Then, initialize the decoder context and dynamically apply for image frame storage space.

[0126] S32: Create ffmpeg to obtain data packets thread, the specific process of the thread is as follows:

[0127] S321: Get the first address pointer bufPtr and length bufLen of the image data array read from the network;

[0128] S322: Determine whether the current data length bufLen is greater than 0, if so, proceed to the next step, if not, wait for the network to send data next time.

[0129] S323: Send the data array first address pointer bufPtr and length bufLen to the soft decoding module, and use the library function av_parser_parse2 to split the data into frames. If a complete image frame data packet can be successfully obtained from the array, record it and continue to the next step. If not, exit the decoding process.

[0130] S324: Save the data packet length ret of the image frame segmentation in this data array, remove the data packet length ret of the image frame segmentation this time from the total length bufLen of the data array, and move the first address pointer bufPtr forward by the number of moves ret.

[0131] S325: Put the complete data packet of the image segmented this time into a queue to be decoded.

[0132] S4: Hard decoding based on acceleration module

[0133] Hard decode the complete data packet after ffmpeg filtering. The specific steps are as follows:

[0134] S41: Set the decoding callback function, as follows:

[0135] S411: Use the library function to obtain the normal frame output of the decoding. If the obtained result is 0, execute the next step, otherwise report an error and exit;

[0136] S412: using library functions to obtain image attribute data output;

[0137] S413: Use library functions to obtain image size, width and height parameter data from output;

[0138] S414: copy the image data and parameter data to the user return array g_send_buf;

[0139] S415: Unlock the semaphore mutex and allow access to the user return array g_send_buf;

[0140] S42: Obtaining a complete image data packet from the decoding queue in step S3;

[0141] S43: Send the data packet to the hard decoding module for decoding, as follows:

[0142] S431: Using library functions to dynamically apply for image storage space;

[0143] S432: Obtaining parameter information of the image frame from ffmpeg;

[0144] S433: Integrate the parameter information and the decoded image data into a complete frame;

[0145] S434: Create an input image stream attribute object;

[0146] S435: Setting input image stream attribute object;

[0147] S436: Dynamically apply for image output memory space;

[0148] S437: Create an output image attribute object;

[0149] S438: Setting output image attributes according to image data, size, and format;

[0150] S439: using the decoding channel attribute, the input image stream attribute, and the output image attribute as parameters and using a library function to send the image frame data to the hard decoding module;

[0151] S4310: Release the requested image memory space;

[0152] S4311: Destroy input image stream object resources;

[0153] S5: Set the error callback function to check the decoding status

[0154] During the decoding process, check in real time whether the decoded image frame can be decoded smoothly. If not, you need to release the resources. The specific steps are as follows:

[0155] S51: Set the error callback function to callbackErr, and the parameter is the exception type object pointer;

[0156] S52: using a library function to obtain the decoding task number taskid in the abnormal situation information;

[0157] S53: Obtain the image frame number frameid of the decoded stream in the abnormal situation information;

[0158] S54: Obtaining the device number in the abnormal situation decoding device;

[0159] S55: Check whether the device ID and task ID in the previous initialization setting are consistent. If yes, use the memory space applied for in process 4 by the image frame number frameid;

[0160] S6: Return the decoded image to the upper layer application through the interface function

[0161] After obtaining the hard-decoded image, the image data is returned through the interface function. The specific steps are as follows:

[0162] S61: Set the readbuf function to obtain the image data interface. The specific contents are as follows:

[0163] S611: The semaphore is locked to prevent read and write conflicts in the user return array;

[0164] S612: copy the decoded image data array g_send_buf in step 4 to the temporary data array g_read_buf;

[0165] S613: Return the image data length;

[0166] S62: Set the function void*getbufAddress to obtain the address of the image data array. This function returns the address of g_read_buf:

[0167] S7: Release the decoding channel resources

[0168] The specific steps are as follows:

[0169] S71: calling a library function to report the decoding thread ID and data stream ID described;

[0170] S72: Set the flag of the decoding thread to false (no decoding);

[0171] S73: Release the decoding thread;

[0172] S74: Destroy the decoding channel object;

[0173] S75: Set the decoding channel description pointer to null;

[0174] S76: Destroy the decoding stream description object;

[0175] S77: Destroy the decoding stream object;

[0176] S78: Set the array array object in the decoded stream to empty.

[0177] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A decoding method for solving timeout memory overflow, characterized in that: The following steps are involved: S1: port ffmpeg to the acceleration module platform; S2: Set up the initialization resource calling interface; S3: Use the ffmpeg dynamic library to obtain the complete compressed image data packet containing the parameter frame; S4: hard decoding based on the acceleration module; S5: Set the error callback function to check the decoding status; S6: Return the decoded image to the upper layer application through the interface function; S7: Release the decoding channel resources.

2. The decoding method for solving timeout memory overflow as claimed in claim 1, characterized in that: Step S1 includes the following process: S11: Configure ffmpeg compilation properties, and configure parameters according to platform type, cpu type, codec properties, format conversion properties, and cross-compilation properties; S12: Modify the acodec.h file, add the parameter frame length sei_len and array sei_buf, and determine its parameter frame size SEI_BUF_SIZE according to the application layer requirements; S13: Add the function of obtaining the parameter frame in the decode_nal_sei_prefix function in the hevc_sei.c file: obtain the parameter size in the function, assign size to sei_len, determine whether size is less than or equal to SEI_BUF_SIZE, and if the condition is met, copy the data in the context parameter array gb to sei_buf, the length of the copy is size, and the array subscript i of the copied sei_buf is the index index of the gb array divided by 8, that is, sei_buf[i]=gb_buf[index / 8]; S14: Execute the configure command to generate decoding libraries libavcodec, libavformat, libavutil, and libswscale in the subfolder lib of the configuration folder; S15: Copy the dynamic library to the / usr / lib path of the decoding board.

3. The decoding method for solving timeout memory overflow as claimed in claim 2, characterized in that: In step S2, the calling interface is set as an external function, parameters and return values ​​are set according to the protocol, and decoding resources are initialized.

4. The decoding method for solving timeout memory overflow as claimed in claim 3, characterized in that: Step S2 includes the following process: S21: Initialize semaphore mutex; S22: Create an initialization resource setting thread, and the main logic content of the thread is set as follows: S221: Setting the hardware decoding device serial number; S222: Use library functions to create a hard decoding context environment; S223: Use library functions to create a hard-decoded data stream object; S224: Create a decoding thread; S225: Initialize ffmpeg resources; S226: Create a network data receiving thread and put the received data into a ring buffer array; S227: Initialize the accelerated decoding module resources. The process is as follows: S2271: Create decoding channel attributes. If the creation is successful, proceed to the next step, otherwise exit with an error; S2272: Set the decoding channel ID number. If the setting is successful, proceed to the next step, otherwise an error is reported and exit; S2273: Set the decoding thread number; S2274: Set the decoding channel callback function. If the setting is successful, proceed to the next step, otherwise exit with an error; S2275: Set the decoding channel error exception callback function. If the setting is successful, proceed to the next step, otherwise report an error and exit; S2276: Set the decoding type of the decoding channel. If the setting is successful, proceed to the next step, otherwise exit with an error; S2277: Set the output image format of the decoding channel. If the setting is successful, proceed to the next step, otherwise exit with an error; S2278: Set the decoding channel output mode. If the setting is successful, proceed to the next step, otherwise exit with an error; S2279: Create a decoding channel according to the decoding channel attributes; S228: Periodically query whether the network has received the image array, that is, whether the ring buffer array has data. If so, take the data according to the frame length specified by the protocol and proceed to the next process. Otherwise, continue to query and wait for network data.

5. The decoding method for solving timeout memory overflow as claimed in claim 4, characterized in that: Step S3 The process includes: S31: Initialize the decoding library usage environment First, set the decoder type and use the HEVC / h265 type decoder; then initialize the decoder context and dynamically apply for image frame storage space; S32: Create ffmpeg to obtain data packets thread, the creation process is as follows: S321: Get the first address pointer bufPtr and length bufLen of the image data array read from the network; S322: Determine whether the current data length bufLen is greater than 0, if so, proceed to the next step, if not, wait for the network to send data next time; S323: Send the data array first address pointer bufPtr and length bufLen to the soft decoding module, and use the library function av_parser_parse2 to split the data into frames. If a complete image frame data packet can be successfully obtained from the array, it will be recorded and continue to the next step. If not, the decoding process will be exited. S324: Save the length ret of the data packet of the image frame segmentation in the data array this time, remove the length ret of the data packet of the image frame segmentation this time from the total length bufLen of the data array, and move the first address pointer bufPtr forward by the number of times ret; S325: Put the complete data packet of the image segmented this time into a queue to be decoded.

6. The decoding method for solving timeout memory overflow as claimed in claim 5, characterized in that: In step S4, the complete data packet filtered by ffmpeg is hard-decoded, and the hard-decoding process is as follows: S41: Set the decoding callback function. The process is as follows: S411: Use the library function to obtain the normal frame output of the decoding. If the obtained result is 0, execute the next step, otherwise report an error and exit; S412: using library functions to obtain image attribute data output; S413: Use library functions to obtain image size, width and height parameter data from output; S414: copy the image data and parameter data to the user return array g_send_buf; S415: Unlock the semaphore mutex and allow access to the user return array g_send_buf; S42: Obtaining a complete image data packet from the decoding queue in step S3; S43: Send the data packet to the hard decoding module for decoding. The process is as follows: S431: Using library functions to dynamically apply for image storage space; S432: Obtaining parameter information of the image frame from ffmpeg; S433: Integrate the parameter information and the decoded image data into a complete frame; S434: Create an input image stream attribute object; S435: Set the input image stream attribute object; S436: Dynamically apply for image output memory space; S437: Create an output image attribute object; S438: Setting output image attributes according to image data, size, and format; S439: using the decoding channel attribute, the input image stream attribute, and the output image attribute as parameters and using a library function to send the image frame data to the hard decoding module; S4310: Release the requested image memory space; S4311: Destroy the input image stream object resources.

7. The decoding method for solving timeout memory overflow as claimed in claim 6, characterized in that: In step S5, during the decoding process, it is checked in real time whether the decoded image frame can be decoded smoothly. If not, resources need to be released. Step S5 includes the following process: S51: Set the error callback function to callbackErr, and the parameter is the exception type object pointer; S52: using a library function to obtain the decoding task number taskid in the abnormal situation information; S53: Obtain the image frame number frameid of the decoded stream in the abnormal situation information; S54: Obtaining the device number in the abnormal situation decoding device; S55: Check whether the device ID and task ID in the previous initialization settings are consistent. If yes, use the memory space applied for in S4 using the image frame number frameid.

8. The decoding method for solving timeout memory overflow as claimed in claim 7, characterized in that: In step S6, after obtaining the hard-decoded image, the image data is returned through the interface function, and the process is as follows: S61: Set the readbuf function to provide an interface for obtaining image data. The process is as follows: S611: The semaphore is locked to prevent read and write conflicts on the array returned to the user; S612: copy the decoded image data array g_send_buf in step 4 to the temporary data array g_read_buf; S613: Return the image data length; S62: Set and provide a function void*getbufAddress for obtaining the address of the image data array, which returns the address of g_read_buf.

9. The decoding method for solving timeout memory overflow as claimed in claim 8, characterized in that: The process of step S7 is as follows: S71: calling a library function to report the decoding thread ID and data stream ID described; S72: Set the flag of the decoding thread to false; S73: Release the decoding thread; S74: Destroy the decoding channel object; S75: Set the decoding channel description pointer to null; S76: Destroy the decoding stream description object; S77: Destroy the decoding stream object; S78: Set the array object in the decoded stream to empty.

10. An application of a decoding method for solving timeout memory overflow according to any one of claims 1 to 9 in the field of video decoding technology under Linux system.

Citation Information

Patent Citations

  • Multi-code-stream decoding acceleration system and method of video decoder

    CN112672166A

  • Video decoding method capable of transcoding

    CN113727114A

  • Multi-channel video decoding method based on dynamic library form

    CN117241036A

  • Method and system for digital decoding 3D stereoscopic video images

    KR1020070011341A

  • Implementation method for driving of software and hardware supporting opensc

    US20160253525A1