A data storage method and device, a vehicle-mounted storage terminal and a storage medium

By determining the buffer capacity coefficient in the data buffer area of ​​the vehicle-mounted storage terminal and adjusting the write parameters, the problem of audio and video data frame loss caused by the deterioration of the storage medium's write card performance was solved, and data integrity was improved.

CN122308702APending Publication Date: 2026-06-30HANGZHOU HIKAUTO SOFTWARE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU HIKAUTO SOFTWARE CO LTD
Filing Date
2024-12-27
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

When recording video for extended periods, the write performance of the storage medium in existing vehicle-mounted storage terminals degrades, leading to frame drops and stuttering in audio and video data, thus compromising data integrity.

Method used

By determining the buffer capacity coefficient in the data buffer area, the write parameters, including the write bitrate and frame rate, are adjusted according to the coefficient to avoid audio and video data congestion and ensure data integrity.

Benefits of technology

This effectively avoids the problem of arbitrary frame loss when writing audio and video data to the storage medium, thus improving data integrity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122308702A_ABST
    Figure CN122308702A_ABST
Patent Text Reader

Abstract

This application provides a data storage method, apparatus, vehicle-mounted storage terminal, and storage medium, relating to the field of data storage technology. In response to an audio / video stream write request, the vehicle-mounted storage terminal determines the current buffer space coefficient of the data buffer based on the positional relationship between the dwell time of the currently written data frame in the data buffer, the current write pointer position, and the current frame start position. Based on the size of the remaining space represented by the current buffer space coefficient, the write parameters for writing data from the data buffer to the storage medium are adjusted. Audio / video data is then retrieved from the data buffer according to the adjusted write parameters and written to the storage medium. In this way, the audio / video data in the data buffer is written to the storage medium according to the adjusted write parameters, avoiding congestion during audio / video stream write requests that could lead to arbitrary frame drops, thereby improving the integrity of the audio / video data written to the storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data storage technology, and in particular to a data storage method, apparatus, vehicle-mounted storage terminal, and storage medium. Background Technology

[0002] In-vehicle storage terminals need to record video in real time for extended periods. In addition to real-time storage, they also have the function of manually copying and exporting data across media or storing data across devices. For example, data collected by a panoramic surround view system can be stored in a dashcam. Therefore, the continuous write performance of storage media such as TF (Trans Flash) cards in in-vehicle storage terminals is required to be high.

[0003] Currently, most service strategies employed are "best-effort" strategies, meaning they try to meet write card requirements as much as possible. However, when multiple storage services concurrently compete for I / O (Input / Output) bandwidth, the integrity of audio and video data cannot be guaranteed. Furthermore, storage media themselves can develop problems over long periods of use. For example, TF cards can experience disk fragmentation after prolonged use, leading to reduced write card performance and an inability to meet the total bandwidth required by storage services. This can result in issues such as dropped frames and stuttering in audio and video data, ultimately compromising the integrity of the stored audio and video data. Summary of the Invention

[0004] The purpose of this application is to provide a data storage method, apparatus, vehicle-mounted storage terminal, and storage medium to ensure the integrity of audio and video data stored in the vehicle-mounted storage terminal. The specific technical solution is as follows:

[0005] In a first aspect, embodiments of this application provide a data storage method applied to an in-vehicle storage terminal. The in-vehicle storage terminal includes a storage medium for storing written audio and video streams and imported audio and video files. The audio and video streams are audio and video data acquired by an image acquisition device, and the audio and video files are imported from other storage media inside the in-vehicle storage terminal, or from storage media outside the in-vehicle storage terminal. The method includes:

[0006] In response to an audio / video stream write request, the current buffer margin coefficient of the data buffer is determined based on the dwell time of the write data frame currently being written to the storage medium in the data buffer, the positional relationship between the current write pointer position and the current used frame start position, wherein the data buffer is used to cache audio / video data acquired from the image acquisition device, the current used frame start position is the position of the write data frame in the data buffer, and the current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the space covered by the write pointer position;

[0007] Based on the size of the remaining space represented by the current cache margin coefficient, the write parameters for writing data from the data cache to the storage medium are adjusted;

[0008] Audio and video data are retrieved from the data buffer according to the adjusted write parameters and written to the storage medium.

[0009] Secondly, embodiments of this application provide a data storage device applied to an in-vehicle storage terminal. The in-vehicle storage terminal includes a storage medium for storing written audio and video streams and imported audio and video files. The audio and video streams are audio and video data acquired by an image acquisition device, and the audio and video files are imported from other storage media inside the in-vehicle storage terminal, or from storage media outside the in-vehicle storage terminal. The device includes:

[0010] The coefficient determination module is used to respond to an audio / video stream write request by determining the current buffer margin coefficient of the data buffer based on the dwell time of the currently written data frame in the data buffer, the positional relationship between the current write pointer position and the current used frame start position. The data buffer is used to cache audio / video data acquired from the image acquisition device. The current used frame start position is the position of the written data frame in the data buffer. The current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the position covered by the write pointer position.

[0011] The write parameter adjustment module is used to adjust the write parameters for writing data from the data cache to the storage medium according to the size of the remaining space represented by the current cache balance coefficient.

[0012] The data storage module is used to retrieve audio and video data from the data buffer according to the adjusted write parameters and write it to the storage medium.

[0013] Thirdly, embodiments of this application provide an in-vehicle storage terminal, including a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement any of the methods described in the first aspect above.

[0014] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the methods described in the first aspect above.

[0015] Beneficial effects of the embodiments in this application:

[0016] In the solution provided in this application embodiment, the vehicle-mounted storage terminal can respond to an audio / video stream write request by determining the current buffer space coefficient of the data buffer based on the dwell time of the currently written data frame in the data buffer, the position of the current write pointer, and the position of the beginning of the currently used frame. The data buffer is used to cache audio / video data acquired from the image acquisition device. The position of the beginning of the currently used frame is the position of the written data frame in the data buffer. The current buffer space coefficient represents the size of the remaining space between the beginning of the currently used frame and the position covered by the write pointer. Then, based on the size of the remaining space represented by the current buffer space coefficient, the write parameters for writing data from the data buffer to the storage medium are adjusted. Audio / video data is then retrieved from the data buffer according to the adjusted write parameters and written to the storage medium. Thus, since the buffer space coefficient can predict whether the audio / video data in the data buffer will be overwritten, and the overwriting of audio / video data reflects the congestion of the audio / video stream write request, this method effectively addresses this issue. Therefore, the write parameters for writing data from the data buffer to the storage medium can be adjusted based on the cache availability coefficient. This ensures that the audio and video data in the data buffer is written to the storage medium according to the adjusted write parameters, preventing congestion during audio and video stream write requests and thus avoiding arbitrary frame drops. This improves the integrity of the audio and video data written to the storage medium. Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above simultaneously. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0018] Figure 1 A flowchart illustrating a data storage method provided in an embodiment of this application;

[0019] Figure 2 For based on Figure 1 A schematic diagram of an in-vehicle storage system provided in the embodiment shown;

[0020] Figure 3 For based on Figure 1 The illustrated embodiment provides a flowchart of a method for writing audio and video data onto a storage medium.

[0021] Figure 4 for Figure 1 A specific flowchart of step S101 in the illustrated embodiment;

[0022] Figure 5(a) shows the results based on Figure 1 The illustrated embodiment provides a first positional relationship between the current write pointer position and the current used frame start position;

[0023] Figure 5(b) shows the results based on Figure 1 The illustrated embodiment provides a second positional relationship between the current write pointer position and the current frame start position;

[0024] Figure 6 For based on Figure 1 The flowchart for adjusting the write parameters provided in the illustrated embodiment;

[0025] Figure 7 for Figure 1 A specific flowchart of step S102 in the illustrated embodiment;

[0026] Figure 8 for Figure 7 A specific flowchart of step S701 in the illustrated embodiment;

[0027] Figure 9 For based on Figure 1 The illustrated embodiment provides a specific flowchart for performing I / O operations on storage requests;

[0028] Figure 10 For based on Figure 1 The illustrated embodiment provides a specific flowchart for responding to various storage requests;

[0029] Figure 11 For based on Figure 1 The illustrated embodiment provides a specific flowchart for I / O scheduling of storage requests;

[0030] Figure 12 This is a schematic diagram of the structure of a data storage device provided in an embodiment of this application;

[0031] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0032] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.

[0033] To ensure the integrity of audio and video data stored in the vehicle-mounted storage terminal, this application provides a data storage method, apparatus, vehicle-mounted storage terminal, computer-readable storage medium, and computer program product. The data storage method provided in this application is described below.

[0034] The data storage method provided in this application can be applied to any in-vehicle storage terminal that needs to store audio and video data, such as a dashcam, in-vehicle hard disk recorder, and in-vehicle storage system, etc., without specific limitations. For clarity, it will be referred to as an in-vehicle storage terminal herein.

[0035] like Figure 1 As shown, a data storage method is applied to an in-vehicle storage terminal. The in-vehicle storage terminal includes a storage medium for storing written audio and video streams and imported audio and video files. The audio and video streams are audio and video data acquired by an image acquisition device, and the audio and video files are imported from other storage media inside the in-vehicle storage terminal, or from storage media outside the in-vehicle storage terminal. The method includes:

[0036] S101, in response to the audio / video stream write request, determine the current buffer capacity coefficient of the data buffer based on the dwell time of the write data frame currently written to the storage medium in the data buffer, the position of the current write pointer, and the position of the beginning of the currently used frame.

[0037] The data buffer is used to cache audio and video data acquired from the image acquisition device. The current frame start position is the position of the written data frame in the data buffer. The current buffer margin coefficient is used to characterize the size of the remaining space between the current frame start position and the position covered by the write pointer.

[0038] S102, adjust the write parameters for writing data from the data cache to the storage medium according to the size of the remaining space represented by the current cache balance coefficient.

[0039] S103, Obtain audio and video data from the data buffer according to the adjusted write parameters, and write it to the storage medium.

[0040] As can be seen, in this embodiment, the vehicle-mounted storage terminal can respond to an audio / video stream write request by determining the current buffer margin coefficient of the data buffer based on the dwell time of the write data frame currently being written to the storage medium in the data buffer, the positional relationship between the current write pointer position and the current used frame start position, where the data buffer is used to buffer audio / video data acquired from the image acquisition device, the current used frame start position is the position of the write data frame in the data buffer, and the current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the position covered by the write pointer position. Then, based on the size of the remaining space represented by the current buffer margin coefficient, the write parameters for writing data from the data buffer to the storage medium are adjusted, and audio / video data is acquired from the data buffer according to the adjusted write parameters and written to the storage medium. Thus, since the buffer margin coefficient can predict the extent to which audio / video data in the data buffer is overwritten, and the extent to which audio / video data is overwritten reflects the congestion situation of the audio / video stream write request. Therefore, the write parameters for writing data from the data cache to the storage medium can be adjusted based on the cache margin coefficient, so that the audio and video data in the data cache is written to the storage medium according to the adjusted write parameters. This avoids congestion of audio and video stream write requests, which could lead to arbitrary frame loss of audio and video data, thereby improving the integrity of the audio and video data written to the storage medium.

[0041] First, we will introduce the in-vehicle storage system, which consists of an in-vehicle storage terminal and other devices with image acquisition capabilities, such as... Figure 2 As shown, an in-vehicle storage system typically consists of an in-vehicle storage terminal, such as a DVR (Digital Video Recorder), an in-vehicle hard disk recorder, and multiple cameras and an in-vehicle controller, such as an AVM (Around View Monitor). The in-vehicle controller inputs audio and video files to the in-vehicle storage terminal via Ethernet. The in-vehicle storage terminal may include storage media such as TF cards and embedded multimedia storage cards such as EMMC (Embedded Multi Media Card).

[0042] The vehicle-mounted storage terminal encodes and encapsulates the images captured by multiple cameras, and categorizes the audio and video streams into normal recording, event recording, and manual recording based on different video triggering conditions. Normal recording is 3 minutes long per segment and is automatically triggered when the camera is powered on; event recording is 30 seconds long per segment, triggered by a specific event, with a 15-second pre-recorded segment and a 15-second recording duration after the event is triggered; manual recording is 30 seconds long and is triggered manually by the user, without pre-recording.

[0043] After the vehicle controller sends audio and video files to the vehicle storage terminal via Ethernet, for example, a panoramic surround view system sends the captured images to a dashcam for storage. The vehicle storage terminal also encodes and encapsulates the images from the vehicle controller, and then stores the audio and video streams into categories such as normal recording, event recording, and manual recording on the storage medium. In addition, there are scenarios where the vehicle storage terminal imports files across media, such as copying audio and video files from the eMMC to a TF card for storage.

[0044] Encoding images can be done by a video encoder encoding the images according to a video encoding standard. The video encoding standard can be determined according to actual needs, such as H.264, H.265, etc. Encapsulating images can be done by a capsule tool encapsulating the images into different video capsule formats. The video capsule format can also be determined according to actual needs, such as AVI (Audio Video Interleave), MKV (Matroska Video File), etc. These are all reasonable and will not be specifically limited here.

[0045] Based on this, the audio and video data stored in the storage medium can be divided into two categories: the first category is the audio and video stream sent by the image acquisition device, and the second category is the audio and video files imported into the storage medium across media. Therefore, a storage request for the audio and video stream sent by the image acquisition device is an audio and video stream write request, while a storage request for the audio and video files imported into the storage medium across media is an audio and video file import request. These audio and video files can be imported from other storage media within the vehicle-mounted storage terminal or from storage media outside the vehicle-mounted storage terminal; both are acceptable.

[0046] As one implementation method, such as Figure 2 As shown, when the in-vehicle storage terminal is a dashcam, the audio and video streams written to the dashcam's storage medium (TF card) are audio and video data captured by the dashcam's built-in camera.

[0047] As one implementation method, the predicted total bandwidth Bw occupied by audio / video stream write requests and audio / video file import requests can be predicted according to the following formula. max :

[0048]

[0049] Where i represents different types of audio and video data, such as regular recording, event recording, manual recording, etc.; Bw export Bandwidth used for importing audio and video files; Bpsi The bitrate of the audio and video data corresponding to the write request for the i-th audio and video stream; t i total The total recording duration for the audio and video data corresponding to the write request for the i-th audio and video stream; t i pre The pre-recording duration for the audio and video data corresponding to the write request for the i-th audio and video stream.

[0050] After obtaining the predicted total bandwidth, compare it with the nominal bandwidth Bw of the storage medium. nominal For example, a CLASS10 TF card typically has a bandwidth of 10 megabits per second, for comparison. Since the actual bandwidth of a storage medium is generally less than its nominal bandwidth, when the nominal bandwidth Bw of the storage medium... nominal Less than the predicted total bandwidth Bw max Or, along with the predicted total bandwidth Bw max When multiple storage requests occur concurrently, an I / O bottleneck can be triggered, potentially leading to data loss for those requests. Since the nominal bandwidth of the storage medium is fixed, when an I / O bottleneck is triggered, the only solution is to reduce the corresponding predicted total bandwidth (Bw). max This can be avoided. Generally, the recording duration of audio and video data cannot be changed. Therefore, as shown in the formula above, the in-vehicle storage terminal can control the bitrate (Bps) of the audio and video data. i And control the bandwidth (Bw) used by audio and video file import requests. export To reduce the predicted total bandwidth Bw max .

[0051] Therefore, the embodiments in this application can reduce the bandwidth occupied by all storage requests by controlling the bitstream of video data, that is, by adjusting the writing parameters of writing data from the data buffer to the storage medium. The writing parameters may include the writing bitrate and the writing frame rate.

[0052] When an image acquisition device needs to store the acquired audio and video streams in the storage medium of an in-vehicle storage terminal, it can send an audio and video stream write request to the in-vehicle storage terminal. In response to the audio and video stream write request, the in-vehicle storage terminal acquires the audio and video data acquired by the image acquisition device and stores it in a data buffer. The storage medium then reads the audio and video data from the data buffer and writes it into the storage medium.

[0053] When the write bandwidth of the storage medium is large enough, audio and video data will be read and written to the storage medium immediately after being written to the data buffer. However, when the input bandwidth of the data buffer is greater than the write bandwidth of the storage medium, the buffer's write pointer will gradually approach the beginning address of the currently written frame data. This means the remaining space between the write pointer position and the beginning of the currently used frame becomes increasingly smaller, leading to congestion in audio and video stream write requests. Therefore, it is necessary to determine the current buffer capacity factor of the data buffer so that the write parameters for writing data from the data buffer to the storage medium can be adjusted using this factor, thus preventing congestion in audio and video stream write requests.

[0054] Therefore, in step S101, the vehicle-mounted storage terminal can respond to the audio and video stream writing request by determining the current buffer capacity coefficient of the data buffer based on the positional relationship between the dwell time of the currently written data frame in the data buffer, the current write pointer position, and the current used frame start position.

[0055] Since the dwell time of the write data frame currently being written from the data buffer to the storage medium represents the waiting time for audio and video data in the data buffer to be written to the storage medium, an excessively long dwell time indicates that the current storage medium is reading data from the data buffer at a relatively slow speed, which means that the write speed from the data buffer to the storage medium is relatively slow, and audio and video stream write requests may experience congestion. The data buffer can be a circular buffer or other types of buffers, without specific limitations here.

[0056] Because data is continuously written to the data buffer via a write pointer, and the speed of writing data to the data buffer is greater than the speed of writing data from the data buffer to the memory medium, data frames that have not yet been written to the storage medium may be overwritten by newly written data frames. Furthermore, if the duration of a written data frame in the data buffer exceeds the maximum duration that the data buffer can store audio and video data, it indicates that the location of that written data frame has already been overwritten.

[0057] The current write pointer position in the data buffer is the position where the audio and video data is currently written into the data buffer, and the current frame start position is the position of the write data frame currently written to the storage medium in the data buffer. Therefore, the positional relationship between the current write pointer position and the current frame start position in the data buffer represents the size of the remaining space in the current data buffer that has not yet been covered.

[0058] Therefore, the current cache reserve coefficient of the data buffer can be determined based on the dwell time of the write data frame currently written to the storage medium in the data buffer area, the positional relationship between the current write pointer position and the current use frame start position; where, the larger the current cache reserve coefficient, the greater the remaining space between the current use frame start position and the write pointer position.

[0059] After determining the current buffer remaining space coefficient, it is important to understand that this coefficient represents the size of the remaining space covered by the write pointer position from the current frame start position. The size of this remaining space reflects the congestion of audio / video stream write requests; a smaller remaining space indicates more severe congestion, leading to arbitrary frame drops during the writing process from the data buffer to the storage medium, potentially causing the written audio / video data to fail to play correctly. To avoid this, in step S102, the write parameters for writing data from the data buffer to the storage medium are adjusted based on the size of the remaining space represented by the current buffer remaining space coefficient.

[0060] The aforementioned write parameters may include write bitrate, write frame rate, write resolution, etc., which are not specifically limited here.

[0061] When the write bandwidth of the storage medium is greater than the input bandwidth of the data buffer, the current cache margin coefficient will approach 1. When the current cache margin coefficient decreases, it indicates that the write bandwidth of the storage medium is less than the input bandwidth of the data buffer, and congestion will occur in audio and video stream write requests. In this case, the write parameters for writing data from the data buffer to the storage medium need to be adjusted; for example, bitrate control can be applied to the write data. Specifically, when the current cache margin coefficient increases, it indicates that the write bandwidth of the storage medium is greater than the input bandwidth of the data buffer, and the bitrate needs to be increased. When the current cache margin coefficient approaches 0, it indicates that even decreasing the bitrate cannot solve the problem of insufficient write bandwidth of the storage medium, and audio and video data in the data buffer will be overwritten. Therefore, the frame rate needs to be decreased to obtain the write parameters for writing data from the data buffer to the storage medium.

[0062] In step S103, after obtaining the adjusted write parameters, audio and video data are retrieved from the data buffer according to the adjusted write parameters and written to the storage medium.

[0063] Since the adjusted write parameters are determined by the size of the remaining space in the data buffer between the current frame start position and the position covered by the write pointer, retrieving audio and video data from the data buffer according to the adjusted write parameters and writing the retrieved audio and video data into the storage medium can effectively avoid the problem of congestion in audio and video stream write requests.

[0064] As one implementation method, such as Figure 3 As shown, methods for retrieving audio and video data from the data buffer and writing it to the storage medium can include:

[0065] For audio and video data acquired by the image acquisition device, the writing parameters of the audio and video data are adjusted using a digital signal processor and a frame reading component. Then, the audio and video data is encoded, and the encoded data frames are written to the data buffer. The frame receiving component in the vehicle-mounted storage terminal continuously updates the write pointer and read pointer, cyclically reading data frames from the data buffer, calculating frame checksums, and adding frame information to the frame queue. Considering the capacity limitations of the storage medium, data frames are not copied to the frame queue of the storage medium. The frame information includes the starting address of the audio and video data frame in the data buffer, the length of the data frame, and the checksum of the data frame.

[0066] When a data frame is needed, i.e., when it needs to be written from the data buffer to the storage medium, the frame reading component retrieves the data frame based on the frame start address and frame length in the frame information. Specifically, it may search for a matching data frame in the data buffer as the target data frame, copy the target data frame from the data buffer, and calculate a checksum for the target data frame. If the checksum matches the checksum indicated by the same frame start address in the frame information, the target data frame is read using the read pointer and written to the storage medium. If the checksum does not match, the target data frame is considered to have been overwritten by a new data frame and is discarded; it will not be written to the storage medium.

[0067] As can be seen in this embodiment, since the cache margin coefficient can predict whether audio and video data in the data cache will be overwritten, and the overwriting of audio and video data reflects the congestion of audio and video stream write requests, the write parameters for writing data from the data cache to the storage medium can be adjusted based on the cache margin coefficient. This ensures that the audio and video data in the data cache is written to the storage medium according to the adjusted write parameters, avoiding congestion in audio and video stream write requests that could lead to arbitrary frame drops, thereby improving the integrity of the audio and video data written to the storage medium.

[0068] As one implementation method of this application, such as Figure 4 As shown, the step of determining the current cache availability coefficient of the data buffer based on the positional relationship between the dwell time of the write data frame currently being written to the storage medium in the data buffer, the current write pointer position, and the beginning position of the currently used frame can include:

[0069] S401, determine the time difference between the current time and the time when the write data frame currently being written to the storage medium arrives at the data buffer, and use this as the dwell time of the write data frame in the data buffer.

[0070] Since after traversing all the storage spaces in the data buffer in the write pointer area, it is possible to turn back and traverse each storage space again from the original position, there is no way to directly determine how much remaining space in the data buffer is before the data of the currently used frame is overwritten based on the positional relationship between the write pointer position and the beginning position of the currently used frame.

[0071] For example, as shown in Figures 5(a) and 5(b), the positional relationship between the write pointer position and the current frame start position is such that, although in Figure 5(a), the write pointer position is before the current frame start position, the current buffer slack factor cannot be directly determined based on this positional relationship. This is because there are two possibilities under this relationship: First, the write pointer position has not yet covered the current frame position, meaning the difference between the write pointer position and the current frame position directly represents the size of the remaining space from the current frame start position to the space covered by the write pointer position. Second, the write pointer position has already covered almost the entire frame, meaning the current frame start position has already been covered. Therefore, the difference between these two positions cannot represent the size of the remaining space from the current frame start position to the space covered by the write pointer position, i.e., the current buffer slack factor.

[0072] The analysis of the positional relationship between the write pointer position and the current frame start position shown in Figure 5(b) is similar to that in Figure 5(a). The current buffer capacity coefficient cannot be determined directly based on the difference between the write pointer position and the current frame start position.

[0073] Therefore, it is necessary to first determine whether the data frame currently using the frame at the beginning of the data buffer has been overwritten by a new data frame by measuring the dwell time of the written data frame in the data buffer. Since the dwell time of the written data frame currently being written from the data buffer to the storage medium refers to the time that the audio and video data in the data buffer waits to be written to the storage medium, a longer dwell time indicates that the current speed of the storage medium reading data from the data buffer is relatively slow. The written data frame has been waiting for a long time in the data buffer before it can be written to the storage medium, which means that there may be congestion in the audio and video stream write request.

[0074] S402, if the dwell time is greater than the data holding time corresponding to the data buffer, determine that the current buffer capacity coefficient is 0.

[0075] The data holding time is the first ratio of the total length of the data buffer to the write bit rate of the data buffer. For example, if the write bit rate of the data buffer is 5 Mbps (Million bits per second) and the total length of the data buffer is 1000 MB (Mbyte), then the data holding time is determined to be 200 seconds; if the write bit rate of the data buffer is 10 Mbps (Million bits per second) and the total length of the data buffer is 8000 MB (Mbyte), then the data holding time is determined to be 800 seconds; if the write bit rate of the data buffer is 8 Mbps (Million bits per second) and the total length of the data buffer is 16000 MB (Mbyte), then the data holding time is determined to be 2000 seconds.

[0076] The data buffer has a limited capacity for audio and video data. Therefore, under normal circumstances, the duration a written data frame remains in the data buffer will not exceed this capacity. Based on this, if the duration a written data frame remains in the data buffer exceeds the corresponding data capacity, it means that the position of the written data frame has been overwritten. In other words, the remaining space in the data buffer between the current frame start position and the position covered by the write pointer is 0, i.e., the current buffer space factor is 0. The current buffer space factor ranges from 0 to 1.

[0077] S403, if the dwell time is not greater than the data holding time corresponding to the data buffer, determine the current buffer capacity coefficient based on the positional relationship between the current write pointer position and the current frame start position.

[0078] If the time a written data frame spends in the data buffer is no longer than the corresponding data holding time of the data buffer, it indicates that the beginning position of the currently used frame in the data buffer has not been overwritten. Therefore, the positional relationship between the write pointer position and the beginning position of the currently used frame can directly characterize how much remaining space is in the data buffer before the data of the currently used frame is overwritten. In other words, the current buffer remaining capacity coefficient can be determined directly based on the positional relationship between the current write pointer position and the beginning position of the currently used frame.

[0079] As can be seen, in this embodiment, since audio and video stream data may be overwritten in the data buffer, the current buffer remaining coefficient cannot be directly determined based on the positional relationship between the write pointer position and the current frame start position. By introducing the data holding time corresponding to the data buffer as an auxiliary judgment, the relationship between the dwell time and the data holding time can be used to determine whether the data buffer has been overwritten. If overwriting has occurred, the current buffer remaining coefficient is directly determined to be 0. Then, if it is determined that the data buffer has not been overwritten, the current buffer remaining coefficient is determined based on the positional relationship between the current write pointer position and the current frame start position. This improves the accuracy of the current buffer remaining coefficient determined by the vehicle storage terminal.

[0080] As one implementation of this application, the step of determining the current buffer slack coefficient based on the positional relationship between the current write pointer position and the current used frame start position may include:

[0081] Determine the size of the storage space between the current write pointer position and the current frame start position; use the second ratio of the storage space size to the total length of the data buffer as the current cache slack coefficient.

[0082] If it is determined that the dwell time of the written data frame in the data buffer is not greater than the data holding time corresponding to the data buffer, that is, if the beginning position of the currently used frame in the data buffer is not overwritten, the size of the storage space between the current write pointer position and the beginning position of the currently used frame can be determined directly based on the positional relationship between the two. Then, the second ratio of the storage space to the total length of the data buffer is calculated as the current buffer slack coefficient.

[0083] As can be seen, in this embodiment of the application, when it is determined that the current frame start position in the data buffer is not currently covered, the ratio of the storage space size between the current write pointer position and the current frame start position to the total length of the data buffer is used as the current cache margin coefficient, so as to facilitate the adjustment of the write parameters for writing data from the data buffer to the storage medium according to the current cache margin coefficient.

[0084] As one embodiment of this application, the step of determining the size of the storage space between the current write pointer position and the current used frame start position may include:

[0085] If the current write pointer position is before the current use frame start position or the current write pointer position is the same as the current use frame start position, calculate the first difference between the current write pointer position and the current use frame start position as the storage space size; if the current write pointer position is after the current use frame start position, calculate the difference between the second difference between the current write pointer position and the current use frame start position and the total length of the data buffer as the storage space size.

[0086] As shown in Figure 5(a), when the current write pointer position is before the current used frame start position, the write pointer does not currently cover the storage space between the current write pointer position and the current used frame position. Therefore, the difference between the current used frame start position and the current write pointer position is the storage space size corresponding to the uncovered audio and video data in the current storage space. Similarly, when the current write pointer position and the current used frame start position are the same, the difference between the current used frame start position and the current write pointer position can also be used as the storage space size.

[0087] As shown in Figure 5(b), when the current write pointer position is after the current use frame start position, the write pointer does not currently cover the storage space after the write pointer or the storage space before the current use frame start position. Therefore, the difference between the second difference between the current write pointer position and the current use frame start position and the total length of the data buffer is the storage space size corresponding to the audio and video data that is not covered in the current storage space.

[0088] As one implementation method, if it is determined that the duration of the written data frame in the data buffer is not greater than the corresponding data holding time of the data buffer, the current buffer sufficiency coefficient k can be calculated according to the following formula:

[0089]

[0090] Among them, L total P is the total length of the data buffer. write P is the current write pointer position. frame This indicates the position of the beginning of the currently used frame.

[0091] Specifically, the vehicle-mounted storage terminal can take the frame information of the write data frame currently being written to the storage medium, the data buffer information, and other information as input. The frame information may include the time uAppTime for the write data frame to be stored in the data buffer and the current frame start position P. Frame Data cache information includes the total length L of the data cache. total and write pointer position P WriteOther information includes the current time uNowTime, the bitrate of the audio and video data uBPs, the dwell time of the written data frame in the data buffer Δt = uNowTime - uAPPTime, and the data holding time corresponding to the data buffer T = L. total / uBPs.

[0092] The vehicle-mounted storage terminal compares the dwell time Δt with the data storage time T. If the dwell time Δt is greater than the data storage time T, it determines the current cache reserve coefficient k to be 0; if the dwell time Δt is not greater than the data storage time T, it compares the current frame start position P. Frame and write pointer position P Write The order of events. At the beginning of the currently used frame, position P... Frame Write pointer position P Write In the subsequent case, determine the current write pointer position P. Write and the current frame start position P Frame The storage space size between uResLen = P Frame -P Write Otherwise, determine the current write pointer position P. Write and the current frame start position P Frame The storage space size between uResLen = L total -P Write +P Frame Then calculate the current cache availability coefficient k = uResLen / L total The larger the current buffer space coefficient k, the greater the remaining space between the current frame start position and the position covered by the write pointer.

[0093] As can be seen, in this embodiment of the application, by different calculation methods based on the different positional relationships between the current write pointer position and the current used frame start position, the current cache balance coefficient can be determined, thereby making the determined current cache balance coefficient accurate.

[0094] Given that the current cache availability coefficient indicates that audio and video stream write requests may experience congestion, the vehicle-mounted storage terminal can reduce the bandwidth occupied by audio and video stream write requests through bitrate control. Bitrate control can be divided into two parts: adjusting the write bitrate and adjusting the write frame rate.

[0095] The principle of bitrate control for audio and video streams is as follows: Figure 6As shown, the current cache availability coefficient is calculated. When the current cache availability coefficient indicates potential congestion in audio / video stream write requests, the in-vehicle storage terminal begins bitrate control for these requests. The expected bitrate is calculated using the current cache availability coefficient, which represents the estimated bitrate for writing data from the data buffer to the storage medium based on the current cache availability coefficient and historical bitrate data. Given the expected bitrate, it is determined whether it is less than the minimum bitrate.

[0096] If not, the onboard storage terminal will directly adjust the target bitrate for writing data from the data buffer to the storage medium to the expected bitrate. If so, because a bitrate that is too low will result in poor audio and video quality, the expected bitrate, which is lower than the minimum bitrate, cannot be set as the target bitrate for writing data from the data buffer to the storage medium. Instead, the minimum bitrate will be set as the target bitrate. In this case, the only way to prevent congestion of audio and video write requests is to reduce the frame rate.

[0097] When the target frame rate is adjusted to the minimum bitrate, the on-board storage terminal calculates the expected frame rate using the current cache reserve coefficient. The expected frame rate represents the frame rate at which data is written from the data buffer to the storage medium, estimated based on the current cache reserve coefficient and historical bitrate data. It then determines whether the expected frame rate is greater than the minimum frame rate. If so, it indicates that the frame rate can be reduced further. Therefore, the corresponding p-frames are discarded according to the expected frame rate to achieve the goal of reducing the frame rate, and the frame rate after discarding the corresponding p-frames is determined as the target frame rate. If not, bitrate control ends.

[0098] As one implementation method of this application, such as Figure 7 As shown, the step of adjusting the write parameters for writing data from the data cache to the storage medium based on the size of the remaining space represented by the current cache availability coefficient may include:

[0099] S701 determines the target bit rate for writing data from the data cache to the storage medium based on the change of the current cache margin coefficient compared to the historical cache margin coefficient, the size of the data cache area, and the bit rate of writing data from the data cache area to the storage medium.

[0100] Among them, the historical cache balance coefficient is the cache balance coefficient corresponding to the historical time before the current time.

[0101] Given the current cache availability coefficient, the change in the current cache availability coefficient compared to the historical cache availability coefficient is determined. Specifically, this involves comparing the remaining space between the current frame start position and the write pointer position with the remaining space between the current frame start position and the write pointer position in a historical timeframe. This change reflects the coverage speed of the write pointer position in the data buffer. Therefore, the vehicle-mounted storage terminal can determine the target bitrate for writing data from the data buffer to the storage medium based on the changes, the size of the data buffer, and the bitrate of writing data from the data buffer to the storage medium.

[0102] The change in the current cache availability coefficient compared to the historical cache availability coefficient can be determined by methods such as the ratio of the current cache availability coefficient to the historical cache availability coefficient, or the difference between the current cache availability coefficient and the historical cache availability coefficient. These methods are all reasonable and will not be specifically limited here.

[0103] As one implementation method, the vehicle-mounted storage terminal can adjust the bit rate of writing data from the data buffer to the storage medium to the target bit rate through a digital signal processor, without making specific limitations here.

[0104] S702, when the target bit rate is the same as the preset minimum bit rate, determines the target frame rate for writing data from the data buffer to the storage medium based on the change of the current buffer margin coefficient compared with the historical buffer margin coefficient and the frame rate of writing data from the data buffer to the storage medium.

[0105] When the target bitrate is the same as the preset minimum bitrate, further reducing the bitrate will result in excessively poor video quality. Therefore, at this point, it is no longer possible to avoid congestion by continuing to reduce the bitrate; the only solution is to reduce the frame rate. The in-vehicle storage terminal can determine the target frame rate for writing data from the data buffer to the storage medium based on the change in the current cache availability coefficient compared to the historical cache availability coefficient and the frame rate at which data is written from the data buffer to the storage medium.

[0106] As one implementation method, the vehicle-mounted storage terminal can adjust the frame rate of writing data from the data buffer to the storage medium to the target frame rate through the frame reading component, without making specific limitations here.

[0107] The S703 writes audio and video data from the data buffer to the storage medium according to the target bit rate and target frame rate.

[0108] Once the target bitrate and target frame rate are determined, audio and video data are written to the storage medium according to the target bitrate and target frame rate.

[0109] As can be seen, in this embodiment, the vehicle-mounted storage terminal determines the target bitrate and the target frame rate for writing data from the data buffer to the storage medium, and writes audio and video data from the data buffer to the storage medium based on the target bitrate and the target frame rate. This effectively avoids the problem of random frame dropping during the process of writing audio and video data to the storage medium, ensuring the integrity of the audio and video data in the storage medium. Furthermore, the bitrate control method described above can effectively reduce the bandwidth occupied during the storage of audio and video data, thereby achieving congestion avoidance and enabling the storage of more audio and video data with limited bandwidth.

[0110] As one implementation method of this application, such as Figure 8 As shown, the step of determining the target bitrate for writing data from the data cache to the storage medium based on the change in the current cache availability coefficient compared to the historical cache availability coefficient, the size of the data cache, and the bitrate of writing data from the data cache to the storage medium can include:

[0111] S801 calculates the change in bitrate per unit time based on the change in the current cache availability coefficient compared to the historical cache availability coefficient.

[0112] The change in bitrate per unit time represents the change in the current cache margin coefficient compared to the historical cache margin coefficient. If the change in bitrate per unit time is greater than 0, it indicates that the current cache margin coefficient has increased compared to the historical cache margin coefficient, meaning that the write bandwidth of the storage medium is greater than the input bandwidth of the data cache. In this case, the bitrate of writing data from the data cache to the storage medium needs to be increased. If the change in bitrate per unit time is equal to 0, it indicates that the current cache margin coefficient has not changed compared to the historical cache margin coefficient. If the change in bitrate per unit time is less than 0, it indicates that the current cache margin coefficient has decreased compared to the historical cache margin coefficient, meaning that the write bandwidth of the storage medium is less than the input bandwidth of the data cache. In this case, the bitrate of writing data from the data cache to the storage medium needs to be decreased.

[0113] S802 determines the maximum bitrate as the target bitrate for writing data from the data buffer to the storage medium when the bitrate change per unit time is greater than 0 and the historical bitrate is the preset maximum bitrate.

[0114] Among them, the historical code rate is the write code rate of writing data from the data buffer to the storage medium at the corresponding historical moment;

[0115] If the bitrate change per unit time is greater than 0, it indicates that the current cache availability coefficient is greater than the historical cache availability coefficient. In this case, the bitrate of writing data from the data cache to the storage medium needs to be increased. However, since the historical bitrate is already the preset maximum bitrate, there is no room for further increase. Therefore, the maximum bitrate is directly determined as the target bitrate. The preset maximum bitrate can be specifically set according to the storage medium, such as 10Mbps, 8Mbps, 6Mbps, etc., which are all reasonable and are not specifically limited here.

[0116] S803 determines the minimum bitrate as the target bitrate for writing data from the data buffer to the storage medium when the bitrate change per unit time is less than 0 and the historical bitrate is not greater than the minimum bitrate.

[0117] If the bitrate change per unit time is less than 0, it indicates that the current cache availability coefficient is less than the historical cache availability coefficient. In this case, the bitrate of writing data from the data cache to the storage medium needs to be reduced. However, since the historical bitrate is already the preset minimum bitrate, there is no room for further reduction. Therefore, the minimum bitrate is directly set as the target bitrate. The preset minimum bitrate can be specifically set according to the storage medium, such as 1Mbps, 2Mbps, 5Mbps, etc., which are all reasonable and are not specifically limited here.

[0118] S804, provided that the first sum of the bitrate change per unit time and the historical bitrate is not less than the minimum bitrate and not greater than the maximum bitrate, determines the second sum of the historical bitrate and the bitrate change per unit time as the target bitrate for writing data from the data buffer to the storage medium.

[0119] If the sum of the bitrate change per unit time and the historical bitrate is not less than the minimum bitrate and not greater than the maximum bitrate, and the bitrate change per unit time is greater than 0, it means that the bitrate of writing data from the data buffer to the storage medium needs to be increased. In this case, the second sum of the historical bitrate and the bitrate change per unit time that is greater than 0 is determined as the target bitrate. If the bitrate change per unit time is less than 0, it means that the bitrate of writing data from the data buffer to the storage medium needs to be decreased. In this case, the second sum of the historical bitrate and the bitrate change per unit time that is less than 0 is determined as the target bitrate.

[0120] In other words, under these circumstances, the target bitrate may increase or decrease compared to the historical bitrate, depending on the amount of bitrate change per unit time.

[0121] As one implementation method, to facilitate the calculation of the second sum of the historical bitrate and the bitrate change per unit time, the bitrate change per unit time can be rounded first, and then the second sum of the historical bitrate and the rounded bitrate change per unit time can be calculated. For example, if the historical bitrate is 6 Mbps, and the bitrate change per unit time is determined to be 2.7 Mbps, then the bitrate change per unit time is rounded to obtain a bitrate change per unit time of 2 Mbps. The second sum of the historical bitrate and the rounded bitrate change per unit time is then calculated to be 8 Mbps, so 8 Mbps is determined as the target bitrate. If the bitrate change per unit time is determined to be -0.6 Mbps, then the bitrate change per unit time is rounded to obtain a bitrate change per unit time of -1 Mbps. The second sum of the historical bitrate and the rounded bitrate change per unit time is then calculated to be 5 Mbps, so 5 Mbps is determined as the target bitrate.

[0122] As one implementation method, based on the change in the current cache availability coefficient compared to the historical cache availability coefficient and the size of the data buffer, the target bitrate (Bps) can be determined according to the following formula. t :

[0123]

[0124] Where [Δbps] is the coefficient k of the current cache remaining capacity. t and historical cache remaining coefficient k t0 The difference between the current time t and the historical time t0, and the total size C of the data buffer. buf The calculated bitrate change per unit time is rounded down; k t k is the current buffer capacity coefficient at time t; t0 Bpst0 is the historical buffer remaining coefficient at historical time t0; Bpst0 is the actual bitrate value at historical time t0; Bps min Minimum bitrate value (Bps) is the preset value. max The preset maximum bitrate value; where C is the total size of the data buffer. buf The unit can be MB.

[0125] Once the target bit rate is determined, the bit rate at which data is written from the data buffer to the storage medium can be adjusted to the target bit rate using a digital signal processor.

[0126] As can be seen, in this embodiment, the vehicle-mounted storage terminal determines the target bitrate for writing data from the data buffer to the storage medium under different conditions by using the bitrate change per unit time and the relationship between the historical bitrate and the preset maximum and minimum bitrates. Since the bitrate change per unit time indicates the relationship between the write bandwidth of the storage medium and the input bandwidth of the data buffer, writing data to the storage medium according to the target frame rate determined based on the frame rate change per unit time can effectively avoid congestion of audio and video stream write requests.

[0127] As one implementation of this application, the step of determining the target frame rate for writing data from the data cache to the storage medium based on the change of the current cache availability coefficient compared to the historical cache availability coefficient and the frame rate of writing data from the data cache to the storage medium may include:

[0128] When the bitrate change per unit time is greater than 0 and the historical frame rate is the maximum frame rate, the maximum frame rate is determined as the target frame rate for writing data from the data buffer to the storage medium, where the historical frame rate is the write frame rate for writing data from the data buffer to the storage medium at the corresponding historical moment. When the bitrate change per unit time is less than 0 and the historical frame rate is the minimum frame rate, the minimum frame rate is determined as the target frame rate for writing data from the data buffer to the storage medium. In other cases, the first product of the maximum frame rate and the bitrate change per unit time, the third ratio of the first product to the minimum bitrate, and the third sum of the third ratio and the historical frame rate are calculated as the target frame rate for writing data from the data buffer to the storage medium.

[0129] according to Figure 6 The principle of bitrate control for audio and video streams, as shown, is that when the target frame rate for writing data to the storage medium in the data buffer is already the minimum bitrate, it means there is no room to further reduce the bitrate, and the only option is to adjust the frame rate. The in-vehicle storage terminal calculates the expected frame rate using the current buffer capacity coefficient and determines whether the expected frame rate is greater than the minimum frame rate. If so, it means there is still room to reduce the frame rate, so the corresponding p-frames are discarded according to the expected frame rate to achieve the goal of reducing the frame rate, and the frame rate after discarding the corresponding p-frames is determined as the target frame rate. If not, bitrate control ends.

[0130] For example, if the preset minimum frame rate is 10 frames per second, the original frame rate of the audio and video data is 30 frames per second, and the calculated expected frame rate is 25 frames per second, then only one p-frame needs to be discarded every 6 frames of data to obtain the target frame rate of 25 frames per second; if the original frame rate of the audio and video data is 20 frames per second, and the calculated expected frame rate is 15 frames per second, then only one p-frame needs to be discarded every 4 frames of data to obtain the target frame rate of 15 frames per second; if the original frame rate of the audio and video data is 20 frames per second, and the calculated expected frame rate is 10 frames per second, then only one p-frame needs to be discarded every 2 frames of data to obtain the target frame rate of 10 frames per second.

[0131] As one implementation method, based on the change in the current cache slack coefficient compared to the historical cache slack coefficient and the frame rate at which data is written to the storage medium from the data buffer, the target bitrate (Fps) can be determined according to the following formula. t :

[0132]

[0133] Where Δbps is the bitrate change per unit time; [Δbps] is the rounded bitrate change per unit time; Fpst0 is the actual frame rate value at historical time t0; Fps min Minimum frame rate value (Fps) is the preset minimum frame rate. max This is the preset maximum frame rate value; Bps min This is the preset minimum bit rate value.

[0134] If the bitrate change per unit time is greater than 0 and the historical frame rate is the maximum frame rate, the target frame rate is determined to be the maximum frame rate. If the bitrate change per unit time is less than 0 and the historical frame rate is the minimum frame rate, the target frame rate is determined to be the minimum frame rate. In other cases, the first product of the maximum frame rate and the bitrate change per unit time, the third ratio of the first product to the minimum bitrate, and the third sum of the third ratio and the historical frame rate are calculated as the target frame rate for writing data from the data buffer to the storage medium.

[0135] Once the target frame rate is determined, the frame rate at which data is written from the data buffer to the storage medium can be adjusted to the target frame rate using the frame reading component.

[0136] As can be seen, in this embodiment, the vehicle-mounted storage terminal determines the target frame rate for writing data from the data buffer to the storage medium under different conditions by using the unit time bitrate change and the relationship between the historical frame rate and the preset maximum and minimum frame rates. Since the unit time framerate change indicates the relationship between the write bandwidth of the storage medium and the input bandwidth of the data buffer, writing data to the storage medium according to the target frame rate determined based on the unit time framerate change can effectively avoid audio and video stream write request congestion.

[0137] As one implementation of this application, the step of calculating the change in bitrate per unit time based on the change in the current cache availability coefficient compared to the historical cache availability coefficient may include:

[0138] Calculate the first difference between the current cache balance coefficient and the historical cache balance coefficient, and the fourth ratio between the second difference between the current time and the historical time; calculate the second product of the fourth ratio and the total size of the data buffer as the bit rate change per unit time.

[0139] Given the current cache availability coefficient, calculate the ratio between the difference between the current cache availability coefficient and the historical cache availability coefficient, and the difference between the current time and the historical time. Then, multiply this ratio by the total size of the data buffer as the unit time bitrate change of the data buffer.

[0140] As one implementation method, the change in bit rate per unit time Δbps can be calculated using the following formula:

[0141]

[0142] Where, k t k represents the current cache availability coefficient. t0 Here, C represents the historical cache slack coefficient, where t is the current time, t0 is the historical time, and C is the historical cache slack coefficient. buf This represents the total size of the data cache.

[0143] As can be seen, in this embodiment of the application, the vehicle storage terminal can calculate the first difference between the current cache balance coefficient and the historical cache balance coefficient, the fourth ratio between the second difference between the current time and the historical time, and the second product of the fourth ratio and the total size of the data buffer as the unit time bitrate change, so as to facilitate bitrate control of audio and video data using the unit time bitrate change.

[0144] As one embodiment of this application, the audio and video streams include audio and video streams of different service types; before the step of responding to the audio and video stream writing request, the above method further includes:

[0145] Upon receiving a storage request, determine the request tag of the storage request. The storage request is either an audio / video stream writing request or an audio / video file import request. The request tag is used to characterize the priority of the storage request. The priority is determined based on the weight of the service type of the audio / video data indicated by the storage request and the preset bandwidth occupied by the service type. Based on the priority indicated by the request tags of each of the currently obtained storage requests, respond to each storage request.

[0146] To demonstrate the necessity of determining the priority of a storage request through its request tag, QoS (Quality of Service) will be explained:

[0147] QoS, or Quality of Service, aims to provide end-to-end service quality guarantees to meet the diverse needs of various services. QoS does not increase network / storage bandwidth; it is a tool for effectively utilizing existing network / storage resources. It allows different traffic flows to compete unequally for network / storage resources, prioritizing voice, video, and critical data applications within network / storage devices. Storage QoS can be applied to in-vehicle storage systems, enabling in-vehicle storage terminals to allocate storage bandwidth appropriately based on QoS configurations for different storage requests.

[0148] Currently, there are various QoS service models, among which DiffServ (Differentiated Services) is the most widely used. The basic principle of the DiffServ model is to differentiate storage requests, with different storage requests receiving different processing, especially when storage bandwidth is congested, different storage requests will enjoy different levels of processing.

[0149] Based on this, the embodiments of this application introduce an in-vehicle storage QoS scheme at the software level based on the differential service model. While ensuring storage bandwidth, the bandwidth resources of the storage medium are reasonably allocated according to different storage requests, effectively alleviating and controlling the problem of data loss caused by application service contention and storage medium performance degradation.

[0150] Specifically, the in-vehicle storage terminal can predict congestion among storage requests by using the predicted total bandwidth occupied by audio / video stream write requests and audio / video file import requests. It can also perform traffic shaping for audio / video data through bitstream control and schedule storage requests based on their weights and priorities. The mClock algorithm can be used to schedule storage requests in the in-vehicle storage system, effectively addressing the problem of data loss caused by audio / video file import requests and audio / video stream write requests competing for resources.

[0151] Based on the calculation formula for the predicted total bandwidth occupied by the predicted audio / video stream write requests and audio / video file import requests, it can be seen that in addition to audio / video stream write requests, audio / video file import requests also compete for the storage medium's write bandwidth. If the bandwidth of audio / video file import requests is not limited, it may lead to arbitrary frame drops in the audio / video streams corresponding to the audio / video stream write requests due to bandwidth contention among storage requests. Therefore, it is necessary to determine the priority of these requests based on their request tags, so that the vehicle-mounted storage terminal can respond to the corresponding storage requests according to the determined priority.

[0152] Upon receiving a storage request, the vehicle-mounted storage terminal determines a request tag to characterize the priority of the request. If an image acquisition device requests storage of audio / video streams, the request is an audio / video stream write request; if the vehicle-mounted storage terminal requests storage of audio / video files across media, it is an audio / video file import request. Audio / video streams include different service types, and audio / video files include those imported across storage media. Generally, the weighting of audio / video data service types is as follows: event recording has the highest weight, followed by normal recording, manual recording, and finally, imported audio / video files across storage media.

[0153] Audio and video streams can be categorized into three types based on their triggering conditions: normal recording, event recording, and manual recording. Specifically, normal recordings are 3 minutes long and are automatically triggered when the camera is powered on. Event recordings are 30 seconds long and are triggered by a specific event, with a 15-second pre-recorded segment and a 15-second recording duration after the event is triggered. Manual recordings are 30 seconds long and are triggered manually by the user, without pre-recording. These are all reasonable options and will not be specifically limited here.

[0154] Since a higher weight for the service type of audio and video data indicates a more important storage request corresponding to that service type, and that storage request should be processed first; and if the bandwidth pre-occupied by the storage request corresponding to the service type exceeds the nominal bandwidth of the storage medium, it means that the storage medium cannot store the storage request and that the storage request should be processed later, the priority of the storage request can be determined based on the weight of the service type of the audio and video data indicated by the storage request and the pre-occupied bandwidth corresponding to the service type.

[0155] As one implementation method, the vehicle-mounted storage terminal can also respond to the storage requests of CAN (Controller Area Network) and log storage according to the processing method of audio and video stream writing requests and audio and video file requests, and store CAN data and logs in the storage medium. This is all reasonable and will not be specifically limited here.

[0156] As can be seen, in this embodiment, the vehicle-mounted storage terminal not only performs flow control on the audio and video data corresponding to the audio and video stream write requests, but also performs bandwidth control on the audio and video file import requests, ensuring the read and write performance of the storage medium in the vehicle-mounted storage terminal. Furthermore, the vehicle-mounted storage terminal determines the priority of each storage request; therefore, there is no distributed high-concurrency write scenario in this application. Since the vehicle-mounted storage terminal uses a stream control method for congestion control and a weight-based scheduling strategy for storage requests, it can not only control the bandwidth occupied by each audio and video stream write request and audio and video file import request, but also control the size of the audio and video data corresponding to the audio and video stream write requests when the bandwidth of the storage medium is limited.

[0157] This application utilizes an in-vehicle storage QoS scheme to rationally allocate storage medium bandwidth resources according to different storage requests while ensuring storage bandwidth, effectively mitigating and controlling data loss caused by application service contention and storage medium performance degradation. To evaluate the service quality of the in-vehicle storage terminal, the following QoS indicators need to be determined:

[0158] {Reservation(reserved bandwidth):r i Limit (Bandwidth Limit): l i Weight: w i};

[0159]

[0160] Where i represents the different types of audio and video data, such as normal recording, event recording, manual recording, etc.; ri represents the bandwidth occupied by the i-th audio and video stream write request; Bps i The bitrate of the audio and video data corresponding to the write request for the i-th audio and video stream; t i total The total recording duration for the audio and video data corresponding to the write request for the i-th audio and video stream; t i pre The pre-recording duration for the audio and video data corresponding to the write request for the i-th audio and video stream.

[0161] Reservation limits the lower limit of bandwidth used by storage requests; for audio / video stream write requests, it sets the minimum bandwidth based on the bitrate, while for audio / video file import requests, it can be adjusted according to actual conditions. Limit limits the upper limit of bandwidth used by storage requests; for both audio / video stream write and audio / video file import requests, l iIt can be set to the nominal bandwidth of the storage medium or infinity. Weight is used to control the allocation and use of bandwidth resources of the storage medium using a relative proportional control (weighting). Generally, the weighting of audio and video data service types is as follows: event recording has the highest weight, followed by normal recording, manual recording, and finally, audio and video files imported across storage media.

[0162] As one embodiment of this application, the above-mentioned request tag includes a storage bandwidth lower limit tag, a storage bandwidth upper limit tag, and a request weight tag. The step of determining the request tag of the storage request may include:

[0163] Calculate the storage bandwidth lower limit label using the following formula.

[0164]

[0165] in, This is the lower limit label for the storage bandwidth of the (r-1)th storage request for the i-th audio / video stream or audio / video file. Let r be the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The reserved bandwidth in the request tag of the i-th storage request is the reserved bandwidth in the QoS metric of the i-th storage request, and t is the time when the storage request is obtained.

[0166] Calculate the storage bandwidth cap label using the following formula.

[0167]

[0168] in, This is the storage bandwidth limit label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. l represents the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The bandwidth limit in the request tag of the i-th storage request is the bandwidth limit in the QoS metric of the i-th storage request, and t is the time when the storage request is obtained.

[0169] Calculate the request weight label using the following formula.

[0170]

[0171] in, Let w be the request weight label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. it represents the weight parameter in the request tag of the i-th storage request, which is the weight parameter in the QoS metric of the i-th storage request, and t represents the time when the storage request was obtained.

[0172] As one implementation method, since the request weight label is a relative value, if there are still unresponded storage requests in the vehicle storage terminal, when a new storage request arrives at the vehicle storage terminal, it is necessary to readjust the weight label size of all received storage requests, using the smallest P label as the reference point to ensure the relative size of the request weight labels of all received storage requests.

[0173] In other words, the request weight label for storage requests with the business type of event recording is the largest, followed by the request weight labels for storage requests with the business type of ordinary recording and manual recording. The request weight label for storage requests with the business type of importing audio and video files across storage media is the smallest. Then, the storage bandwidth lower limit label, storage bandwidth upper limit label, and request weight label are added for storage requests. Request interfaces with storage media in a blocked state are waiting to be awakened by the scheduling module.

[0174] As one implementation method, the process by which the in-vehicle storage terminal performs I / O operations on a storage request upon receiving it can be as follows: Figure 9 As shown:

[0175] S901, Service i initiates an IO request r;

[0176] S902, Update the P tag for all business requests;

[0177] S903, calculate the P, L, and R tags of request r for service i;

[0178] S904, awaiting wake-up request;

[0179] S905 is used for I / O operations;

[0180] S906, remove all tags from all requests r for all services i.

[0181] After storage service i initiates an IO request r, for the service requests currently acquired by the vehicle-mounted storage terminal, the vehicle-mounted storage terminal updates the P tag (representing the request weight tag) of all requests; then it calculates the P, L, and R tags (representing the request weight tag, storage bandwidth upper limit tag, and storage bandwidth lower limit tag) of service i's request r, and waits for the request to be woken up. If the scheduling module successfully wakes up the IO interface, the vehicle-mounted storage terminal performs the IO operation on the service request. After completing the IO operation on service i's request r, it removes all tags from all service i's request r.

[0182] As can be seen, in this embodiment of the application, the request tag can be a combination of a storage bandwidth lower limit tag, a storage bandwidth upper limit tag, and a request weight tag triple. The vehicle storage terminal can use the above formula to calculate the storage bandwidth lower limit tag, the storage bandwidth upper limit tag, and the request weight tag respectively, so as to accurately determine the request tag corresponding to the storage request.

[0183] As one implementation method of this application, such as Figure 10 As shown, the steps for responding to each storage request based on the priority indicated by the request tags of each currently acquired storage request include:

[0184] S1001, determine whether there is a first storage request among the various storage requests whose corresponding storage bandwidth lower limit label is greater than the current time.

[0185] Since the storage bandwidth lower limit label in the storage request represents the maximum time the vehicle-mounted storage terminal can respond to the storage request when the bandwidth occupied by the storage request is the lower limit of the storage medium's bandwidth, if the storage bandwidth lower limit label is greater than the current time, it means that the storage terminal's response time to the storage request has timed out, and the timed-out storage requests need to be processed first.

[0186] For example, if the current system time of the vehicle storage is 10:30, the lower limit label of the storage bandwidth for storage request A is 10:28, and the lower limit label of the storage bandwidth for storage request B is 10:33, it is clear that the response time of the vehicle storage terminal to storage request A has exceeded the time limit. Therefore, the priority of storage request A is higher than that of storage request B, and the vehicle storage terminal will respond to storage request A first.

[0187] S1002, if a first storage request exists, wake up the response interface of the storage medium so that the response interface responds to the first storage request.

[0188] If it is determined that there is a timed-out first storage request among the storage requests received by the vehicle storage terminal, the scheduling module can wake up the response interface of the storage medium that is in a blocked state, so that the vehicle storage terminal can respond to the first storage request through the response interface and process it.

[0189] S1003, if there is no first storage request, or if the first storage request has been processed, determine from the remaining storage requests a second storage request whose corresponding storage bandwidth upper limit label is not greater than the current time.

[0190] Since the storage bandwidth limit label represents the shortest time for the in-vehicle storage terminal to respond to a storage request when the bandwidth occupied by the storage request is the limited bandwidth or infinity specified in the request label of the i-th storage request, if the storage bandwidth limit label exceeds the current time, it means that for that storage request, even if the bandwidth occupied is the limited bandwidth or infinity specified in the request label of the i-th storage request, the storage medium cannot write the audio and video data corresponding to the storage request. Therefore, the storage medium can only write the audio and video data corresponding to the storage request if the storage bandwidth limit label is not greater than the current time.

[0191] Based on this, if it is determined that there is no timed-out first storage request among the storage requests received by the vehicle storage terminal, or if the timed-out first storage request has been processed, the vehicle storage terminal can determine that the corresponding storage bandwidth upper limit label is not greater than the second storage request at the current time.

[0192] S1004. Process the second storage request according to the priority order indicated by the request weight label corresponding to the second storage request.

[0193] Since the audio and video data corresponding to the second storage request is writable on the storage medium, once the second storage request is determined, it can be processed according to the priority order indicated by the request weight label of the second storage request.

[0194] Generally, the storage request with the service type of event recording has the highest request weight label, followed by the storage requests with the service types of normal recording and manual recording. The storage request with the service type of importing audio and video files across storage media has the lowest request weight label. Therefore, the storage terminal can process the second storage request according to the priority order indicated by the above weights. The larger the request weight label of the storage request, the higher the priority of the storage request.

[0195] For example, the vehicle-mounted storage terminal receives storage requests including storage request A through storage request D. Storage request A has a request weight label of 0.6, storage request B has a request weight label of 0.2, storage request C has a request weight label of 0.05, and storage request D has a request weight label of 0.15. Therefore, according to the relationship between the request weight labels of these four storage requests, the priority order is determined as storage request A, storage request B, storage request D, and storage request C.

[0196] As can be seen, in this embodiment of the application, the vehicle-mounted storage terminal can dynamically schedule storage requests of different service types based on the bandwidth occupied by each storage request and the weight of different storage requests, thereby solving the problem of storage request congestion.

[0197] As one embodiment of this application, the step of waking up the response interface of the storage medium to respond to the first storage request when a first storage request exists may include:

[0198] The processing order of the first storage request is determined according to the storage bandwidth lower limit label in ascending order; the response interface of the storage medium is woken up so that the response interface responds to the corresponding first storage request based on the processing order.

[0199] Although the first storage request is always a request whose response time has exceeded the current time, the excess time of each first storage request may be different. The longer the excess time, the longer the storage request will wait for a response. Therefore, the storage request with the longest excess time, which is the storage bandwidth lower limit label, should be processed first. Then, other storage requests should be processed in order of increasing storage bandwidth lower limit label.

[0200] For example, if the current system time of the vehicle storage is 10:30, the lower limit label of the storage bandwidth for the first storage request A is 10:28, the lower limit label of the storage bandwidth for the first storage request B is 10:25, and the lower limit label of the storage bandwidth for the first storage request C is 10:29. Obviously, the lower limit label of the storage bandwidth for the first storage request B is the smallest, and the timeout duration is the longest, which is 5 minutes. Therefore, the processing order of the response interface for the above first storage requests is first storage request B, first storage request A, and first storage request C.

[0201] As can be seen, in this embodiment of the application, the vehicle-mounted storage terminal will prioritize processing the first storage request with a longer timeout duration, i.e. a smaller storage bandwidth lower limit label, so that the audio and video data corresponding to the first storage request with a longer timeout duration can be written into the storage medium as soon as possible.

[0202] As one embodiment of this application, before the step of determining the request tag of the storage request, the above may further include:

[0203] Based on the business type corresponding to the current storage request and the business type corresponding to the historical storage requests, the request weight label corresponding to the historical storage requests is adjusted according to the weight setting rules.

[0204] Since the request weight label is a relative value, if there are still unresponded storage requests in the vehicle storage terminal, when a new storage request arrives at the vehicle storage terminal, the weight label size of all received storage requests needs to be readjusted, using the smallest P label as the reference point to ensure the relative size of the request weight labels of all received storage requests.

[0205] For example, the in-vehicle storage terminal has not yet processed storage requests including video stream write request A (service type: event recording) and audio / video file import request B. The request weight label for video stream write request A is 0.8, and the request weight label for audio / video file import request B is 0.2. If another request is received, the in-vehicle storage terminal needs to recalculate the request weight labels for all storage requests to obtain the current request weight labels: the request weight label for video stream write request A is 0.64, the request weight label for audio / video file import request B is 0.16, and the request weight label for video stream write request C is 0.4.

[0206] As can be seen, in this embodiment of the application, since the request weight label is a relative value, when the vehicle storage terminal receives a storage request, it is necessary to redetermine the request weight label of the currently acquired storage request so that the request weight label of the storage request is accurate, thereby improving the accuracy of the priority represented by the label of the storage request.

[0207] As one implementation method, such as Figure 11 As shown, when the vehicle-mounted storage terminal receives a storage request, it can perform I / O scheduling on the storage request according to the following process.

[0208] S1101, Initialize the scheduling thread;

[0209] S1102, obtain the set E of R tags for all IO requests that are less than the current time t;

[0210] S1103, E is not empty;

[0211] S1104, wake up the IO request blocked by the smallest R tag according to the R tag order;

[0212] S1105, Get the set F of L tags for all IO requests that are less than the current time t;

[0213] S1106, F is not empty;

[0214] S1107, wake up the IO request blocked by the smallest P tag in the F set.

[0215] The vehicle-mounted storage terminal initializes the scheduling thread, and then obtains the set E of R tags for all IO requests less than the current time t. If set E is successfully obtained, it checks whether E is not empty. If it is, it wakes up the IO request blocked by the smallest R tag in set E according to the R tag order, processes it to complete the IO request processing, and then returns to the step of obtaining the set E of R tags for all IO requests less than the current time t.

[0216] If not, the vehicle storage terminal obtains the set F of L tags for all IO requests less than the current time t, and determines whether F is not empty. If it is, it wakes up the IO request blocked by the smallest P tag in the set F and processes it to complete the IO request processing. If not, it returns to the step of obtaining the set E of R tags for all IO requests less than the current time t.

[0217] As can be seen, in this embodiment, storage requests are divided into audio / video stream write requests and audio / video file import requests. For audio / video stream write requests, the congestion of storage requests is predicted by calculating the current buffer space coefficient, and the bitrate and frame rate of writing data from the data buffer to the storage medium are dynamically adjusted according to the current buffer space coefficient to solve the storage congestion problem. Simultaneously, for both audio / video stream write requests and audio / video file import requests, the vehicle-mounted storage terminal, based on the mClock algorithm and the type of storage request, can dynamically schedule the bandwidth of different types of storage requests according to their weights. This reduces the problem of random data loss caused by insufficient storage medium bandwidth in the vehicle-mounted storage terminal, while also optimizing the problem of data loss caused by competition for storage requests from different services, thus enhancing the product experience. Unlike the original mClock algorithm, the scheduling algorithm in this application has at most one storage request per service type at a time, so there is no need to readjust the position of the lower limit label of storage bandwidth at the end of the Weight phase, reducing the data processing pressure on the vehicle-mounted storage terminal.

[0218] Corresponding to the data storage method described above, this application also provides a data storage device. The data storage device provided in this application embodiment will be described below.

[0219] like Figure 12 As shown, a data storage device is applied to an in-vehicle storage terminal. The in-vehicle storage terminal includes a storage medium for storing written audio and video streams and imported audio and video files. The audio and video streams are audio and video data acquired by an image acquisition device. The audio and video files are imported from other storage media inside the in-vehicle storage terminal, or from storage media outside the in-vehicle storage terminal. The device includes:

[0220] The coefficient determination module 1201 is used to respond to an audio / video stream write request by determining the current buffer margin coefficient of the data buffer based on the dwell time of the write data frame currently written to the storage medium in the data buffer, the positional relationship between the current write pointer position and the current used frame start position, wherein the data buffer is used to cache audio / video data acquired from the image acquisition device, the current used frame start position is the position of the write data frame in the data buffer, and the current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the space covered by the write pointer position;

[0221] The write parameter adjustment module 1202 is used to adjust the write parameters for writing data from the data cache to the storage medium according to the size of the remaining space represented by the current cache balance coefficient.

[0222] The data storage module 1203 is used to obtain audio and video data from the data buffer according to the adjusted write parameters and write it to the storage medium.

[0223] As can be seen, in this embodiment, the vehicle-mounted storage terminal can respond to an audio / video stream write request by determining the current buffer margin coefficient of the data buffer based on the dwell time of the write data frame currently being written to the storage medium in the data buffer, the positional relationship between the current write pointer position and the current used frame start position, where the data buffer is used to buffer audio / video data acquired from the image acquisition device, the current used frame start position is the position of the write data frame in the data buffer, and the current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the position covered by the write pointer position. Then, based on the size of the remaining space represented by the current buffer margin coefficient, the write parameters for writing data from the data buffer to the storage medium are adjusted, and audio / video data is acquired from the data buffer according to the adjusted write parameters and written to the storage medium. Thus, since the buffer margin coefficient can predict the extent to which audio / video data in the data buffer is overwritten, and the extent to which audio / video data is overwritten reflects the congestion situation of the audio / video stream write request. Therefore, the write parameters for writing data from the data cache to the storage medium can be adjusted based on the cache margin coefficient, so that the audio and video data in the data cache is written to the storage medium according to the adjusted write parameters. This avoids congestion of audio and video stream write requests, which could lead to arbitrary frame loss of audio and video data, thereby improving the integrity of the audio and video data written to the storage medium.

[0224] As one embodiment of this application, the coefficient determination module 1201 described above may include:

[0225] The dwell time determination submodule is used to determine the time difference between the current time and the time when the write data frame currently written to the storage medium arrives at the data buffer, and use this as the dwell time of the write data frame in the data buffer;

[0226] The coefficient first determination submodule is used to determine that the current cache balance coefficient is 0 when the dwell time is greater than the data storage time corresponding to the data cache area, wherein the data storage time is the first ratio of the total length of the data cache area to the write code rate of the data cache area;

[0227] The second coefficient determination submodule is used to determine the current cache balance coefficient based on the positional relationship between the current write pointer position and the current used frame start position, provided that the dwell time is not greater than the data storage time corresponding to the data buffer.

[0228] As one embodiment of this application, the above-mentioned second coefficient determination submodule may include:

[0229] The storage space determination unit is used to determine the size of the storage space between the current write pointer position and the current used frame start position;

[0230] The coefficient determination unit is used to take the second ratio of the storage space size to the total length of the data cache as the current cache availability coefficient.

[0231] As one embodiment of this application, the above-mentioned storage space determination unit can be specifically used for:

[0232] If the current write pointer position is before the current use frame start position or the current write pointer position is the same as the current use frame start position, calculate the first difference between the current write pointer position and the current use frame start position as the storage space size; if the current write pointer position is after the current use frame start position, calculate the difference between the second difference between the current write pointer position and the current use frame start position and the total length of the data buffer as the storage space size.

[0233] As one embodiment of this application, the above-described parameter adjustment module 1202 may include:

[0234] The target bitrate determination submodule is used to determine the target bitrate for writing data from the data cache to the storage medium based on the change of the current cache balance coefficient compared with the historical cache balance coefficient, the size of the data cache area, and the bitrate of writing data from the data cache area to the storage medium. The historical cache balance coefficient is the cache balance coefficient corresponding to the historical time before the current time.

[0235] The target frame rate determination submodule is used to determine the target frame rate for writing data from the data buffer to the storage medium, based on the change of the current buffer margin coefficient compared with the historical buffer margin coefficient and the frame rate of writing data from the data buffer to the storage medium, when the target bit rate is the same as the preset minimum bit rate.

[0236] The data writing submodule is used to write audio and video data from the data buffer to the storage medium according to the target bitrate and target frame rate.

[0237] As one embodiment of this application, the target bitrate determination submodule may include:

[0238] The change determination unit is used to calculate the change in bit rate per unit time based on the change in the current cache availability coefficient compared to the historical cache availability coefficient.

[0239] The first target bitrate determination unit is used to determine the maximum bitrate as the target bitrate for writing data from the data buffer to the storage medium when the bitrate change per unit time is greater than 0 and the historical bitrate is the preset maximum bitrate. The historical bitrate is the write bitrate for writing data from the data buffer to the storage medium at the corresponding historical moment.

[0240] The second target bitrate determination unit is used to determine the minimum bitrate as the target bitrate for writing data from the data buffer to the storage medium when the bitrate change per unit time is less than 0 and the historical bitrate is not greater than the minimum bitrate.

[0241] The third target bitrate determination unit is used to determine the second sum of the historical bitrate and the bitrate change per unit time as the target bitrate for writing data from the data buffer to the storage medium, provided that the first sum of the bitrate change per unit time and the historical bitrate is not less than the minimum bitrate and not greater than the maximum bitrate.

[0242] As one embodiment of this application, the target frame rate determination submodule may include:

[0243] The first target frame rate determination unit is used to determine the maximum frame rate as the target frame rate for writing data from the data buffer to the storage medium when the bit rate change per unit time is greater than 0 and the historical frame rate is the maximum frame rate. The historical frame rate is the write frame rate for writing data from the data buffer to the storage medium at the corresponding historical moment.

[0244] The second target frame rate determination unit is used to determine the minimum frame rate as the target frame rate for writing data from the data buffer to the storage medium when the bit rate change per unit time is less than 0 and the historical frame rate is the minimum frame rate.

[0245] The third target frame rate determination unit is used to calculate, under other circumstances, the first product value of the maximum frame rate and the unit time bit rate change, the third ratio of the first product value and the minimum bit rate, and determine the third ratio and the third sum of the historical frame rates as the target frame rate for writing data from the data buffer to the storage medium.

[0246] As one embodiment of this application, the above-mentioned change determination unit can be specifically used for:

[0247] Calculate the first difference between the current cache balance coefficient and the historical cache balance coefficient, and the fourth ratio between the second difference between the current time and the historical time.

[0248] The second product of the fourth ratio and the total size of the data buffer is calculated as the change in bit rate per unit time.

[0249] As one embodiment of this application, the above-described apparatus may further include:

[0250] The request tag determination module is used to determine the request tag of the storage request when a storage request is obtained. The storage request is an audio / video stream writing request or an audio / video file import request. The request tag is used to characterize the priority of the storage request. The priority is determined based on the weight of the service type of the audio / video data indicated by the storage request and the preset bandwidth occupied by the service type.

[0251] The request-response module is used to respond to each storage request based on the priority indicated by the request tags of each of the currently acquired storage requests.

[0252] As one embodiment of this application, the request tag may include a storage bandwidth lower limit tag, a storage bandwidth upper limit tag, and a request weight tag. The request tag determination module may include:

[0253] The first calculation submodule is used to calculate the storage bandwidth lower limit label according to the following formula.

[0254]

[0255] in, This is the lower limit label for the storage bandwidth of the (r-1)th storage request for the i-th audio / video stream or audio / video file. Let r be the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The reserved bandwidth is specified in the request tag of the i-th storage request, and t is the time when the storage request is obtained.

[0256] The second calculation submodule is used to calculate the storage bandwidth limit label according to the following formula.

[0257]

[0258] in, This is the storage bandwidth limit label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. l represents the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The bandwidth limit is defined in the request tag of the i-th storage request, and t is the time when the storage request was obtained.

[0259] The third calculation submodule is used to calculate the request weight label according to the following formula.

[0260]

[0261] in, Let w be the request weight label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. i t represents the weight parameter in the request tag of the i-th storage request, and t represents the time when the storage request was obtained.

[0262] As one embodiment of this application, the above-mentioned request response module may include:

[0263] The first storage request determination submodule is used to determine whether there is a first storage request in each storage request whose corresponding storage bandwidth lower limit label is greater than the current time.

[0264] The request and response first submodule is used to wake up the response interface of the storage medium in the event of a first storage request, so that the response interface responds to the first storage request;

[0265] The second storage request determination submodule is used to determine, from the remaining storage requests, a second storage request whose corresponding storage bandwidth upper limit label is not greater than the current time, in the case that there is no first storage request or the first storage request has been processed.

[0266] The second storage request processing submodule is used to process the second storage request according to the priority order indicated by the request weight tag corresponding to the second storage request.

[0267] As one implementation of this application, the above-mentioned request response first submodule may include:

[0268] The sequence determination unit is used to determine the processing order of the first storage request according to the storage bandwidth lower limit label in ascending order;

[0269] The request-response unit is used to wake up the response interface of the storage medium so that the response interface responds to the first storage request based on the processing order.

[0270] As one embodiment of this application, the above-described apparatus may further include:

[0271] The request weight label adjustment module is used to adjust the request weight label corresponding to the historical storage request based on the business type corresponding to the currently obtained storage request and the business type corresponding to the historical storage request, according to the weight setting rules.

[0272] In the technical solution of this application, the acquisition, storage, use, processing, transmission, provision and disclosure of audio and video data are all carried out with the user's authorization.

[0273] This application also provides an electronic device, such as... Figure 13 As shown, it includes:

[0274] Memory 1301 is used to store computer programs;

[0275] When processor 1302 executes the program stored in memory 1301, it performs the following steps:

[0276] As can be seen, in this embodiment, the vehicle-mounted storage terminal can respond to an audio / video stream write request by determining the current buffer margin coefficient of the data buffer based on the dwell time of the write data frame currently being written to the storage medium in the data buffer, the positional relationship between the current write pointer position and the current used frame start position, where the data buffer is used to buffer audio / video data acquired from the image acquisition device, the current used frame start position is the position of the write data frame in the data buffer, and the current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the position covered by the write pointer position. Then, based on the size of the remaining space represented by the current buffer margin coefficient, the write parameters for writing data from the data buffer to the storage medium are adjusted, and audio / video data is acquired from the data buffer according to the adjusted write parameters and written to the storage medium. Thus, since the buffer margin coefficient can predict the extent to which audio / video data in the data buffer is overwritten, and the extent to which audio / video data is overwritten reflects the congestion situation of the audio / video stream write request. Therefore, the write parameters for writing data from the data cache to the storage medium can be adjusted based on the cache margin coefficient, so that the audio and video data in the data cache is written to the storage medium according to the adjusted write parameters. This avoids congestion of audio and video stream write requests, which could lead to arbitrary frame loss of audio and video data, thereby improving the integrity of the audio and video data written to the storage medium.

[0277] Furthermore, the aforementioned electronic device may also include a communication bus and / or a communication interface, with the processor 1302, the communication interface, and the memory 1301 communicating with each other via the communication bus.

[0278] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0279] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0280] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0281] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0282] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the above data storage methods.

[0283] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the data storage methods described above.

[0284] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state drive (SSD), etc.

[0285] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0286] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of the device, vehicle-mounted storage terminal, computer-readable storage medium, and computer program product are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0287] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A data storage method, characterized by, An application is made to an in-vehicle storage terminal, the in-vehicle storage terminal including a storage medium for storing written audio and video streams and imported audio and video files, wherein the audio and video streams are audio and video data acquired by an image acquisition device, and the audio and video files are imported from other storage media inside the in-vehicle storage terminal, or from storage media outside the in-vehicle storage terminal, the method comprising: In response to an audio / video stream write request, the current buffer margin coefficient of the data buffer is determined based on the dwell time of the write data frame currently being written to the storage medium in the data buffer, the positional relationship between the current write pointer position and the current used frame start position, wherein the data buffer is used to cache audio / video data acquired from the image acquisition device, the current used frame start position is the position of the write data frame in the data buffer, and the current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the space covered by the write pointer position; Based on the size of the remaining space represented by the current cache margin coefficient, the write parameters for writing data from the data cache to the storage medium are adjusted; Audio and video data are retrieved from the data buffer according to the adjusted write parameters and written to the storage medium.

2. The method of claim 1, wherein, The step of determining the current cache slack coefficient of the data buffer based on the positional relationship between the dwell time of the write data frame currently written to the storage medium in the data buffer, the current write pointer position, and the current frame start position includes: The time difference between the current time and the time when the write data frame currently being written to the storage medium arrives at the data buffer is determined as the dwell time of the write data frame in the data buffer; If the dwell time is greater than the data storage time corresponding to the data buffer, the current cache balance coefficient is determined to be 0, wherein the data storage time is a first ratio of the total length of the data buffer to the write code rate of the data buffer; If the dwell time is not greater than the data holding time corresponding to the data buffer, the current buffer capacity coefficient is determined based on the positional relationship between the current write pointer position and the current used frame start position.

3. The method of claim 2, wherein, The step of determining the current buffer slack coefficient based on the positional relationship between the current write pointer position and the current used frame start position includes: Determine the size of the storage space between the current write pointer position and the current used frame start position; The second ratio of the storage space size to the total length of the data cache area is used as the current cache availability coefficient.

4. The method of claim 3, wherein, The step of determining the size of the storage space between the current write pointer position and the current used frame start position includes: If the current write pointer position is before the current use frame start position or the current write pointer position is the same as the current use frame start position, calculate the first difference between the current write pointer position and the current use frame start position as the storage space size; If the current write pointer position is after the current used frame start position, the difference between the second difference between the current write pointer position and the current used frame start position and the total length of the data buffer is calculated as the storage space size.

5. The method of claim 1, wherein, The step of adjusting the write parameters for writing data from the data cache to the storage medium based on the remaining space represented by the current cache availability coefficient includes: Based on the change of the current cache balance coefficient compared to the historical cache balance coefficient, the size of the data cache area, and the bit rate of writing data from the data cache area to the storage medium, the target bit rate of writing data from the data cache area to the storage medium is determined, wherein the historical cache balance coefficient is the cache balance coefficient corresponding to the historical time before the current time. When the target bitrate is the same as the preset minimum bitrate, the target frame rate for writing data from the data buffer to the storage medium is determined based on the change of the current buffer margin coefficient compared with the historical buffer margin coefficient and the frame rate of writing data from the data buffer to the storage medium. Audio and video data are written from the data buffer to the storage medium according to the target bitrate and the target frame rate.

6. The method according to claim 5, characterized in that, The step of determining the target bitrate for writing data from the data cache to the storage medium based on the change of the current cache availability coefficient compared to the historical cache availability coefficient, the size of the data cache, and the bitrate of writing data from the data cache to the storage medium includes: The change in bitrate per unit time is calculated based on the change in the current cache availability coefficient compared to the historical cache availability coefficient. When the unit time bitrate change is greater than 0 and the historical bitrate is a preset maximum bitrate, the maximum bitrate is determined as the target bitrate for writing data from the data buffer to the storage medium, wherein the historical bitrate is the write bitrate for writing data from the data buffer to the storage medium at the historical moment. If the bitrate change per unit time is less than 0 and the historical bitrate is not greater than the minimum bitrate, the minimum bitrate is determined as the target bitrate for writing data from the data buffer to the storage medium. If the first sum of the bitrate change per unit time and the historical bitrate is not less than the minimum bitrate and not greater than the maximum bitrate, the second sum of the historical bitrate and the bitrate change per unit time is determined as the target bitrate for writing data from the data buffer to the storage medium.

7. The method according to claim 6, characterized in that, The step of determining the target frame rate for writing data from the data cache to the storage medium based on the change of the current cache availability coefficient compared to the historical cache availability coefficient and the frame rate of writing data from the data cache to the storage medium includes: When the bitrate change per unit time is greater than 0 and the historical frame rate is the maximum frame rate, the maximum frame rate is determined as the target frame rate for writing data from the data buffer to the storage medium, wherein the historical frame rate is the write frame rate for writing data from the data buffer to the storage medium corresponding to the historical moment. When the bitrate change per unit time is less than 0 and the historical frame rate is the minimum frame rate, the minimum frame rate is determined as the target frame rate for writing data from the data buffer to the storage medium. In other cases, a first product of the maximum frame rate and the unit time bitrate change, a third ratio of the first product and the minimum bitrate are calculated, and the third ratio and the third sum of the historical frame rates are determined as the target frame rate for writing data from the data buffer to the storage medium.

8. The method according to claim 6, characterized in that, The step of calculating the change in bitrate per unit time based on the change in the current cache availability coefficient compared to the historical cache availability coefficient includes: Calculate the first difference between the current cache balance coefficient and the historical cache balance coefficient, and the fourth ratio between the second difference between the current time and the historical time; The second product of the fourth ratio and the total size of the data buffer is calculated as the bitrate change per unit time.

9. The method according to any one of claims 1-8, characterized in that, The audio and video streams include audio and video streams of different service types; Prior to the step of responding to the audio / video stream write request, the method further includes: Upon receiving a storage request, the request tag of the storage request is determined, wherein the storage request is an audio / video stream writing request or an audio / video file import request, and the request tag is used to characterize the priority corresponding to the storage request. The priority is determined based on the weight of the service type of the audio / video data indicated by the storage request and the preset bandwidth occupied by the service type. Respond to each storage request based on the priority indicated by the request tags of each of the currently acquired storage requests.

10. The method according to claim 9, characterized in that, The request tag includes a storage bandwidth lower limit tag, a storage bandwidth upper limit tag, and a request weight tag. The step of determining the request tag of the storage request includes: The storage bandwidth lower limit label is calculated using the following formula. Among them, the This is the lower limit label for the storage bandwidth of the (r-1)th storage request for the i-th audio / video stream or audio / video file. Let r be the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The reserved bandwidth in the request tag of the i-th storage request, and t is the time when the storage request is obtained; The storage bandwidth upper limit label is calculated using the following formula. Among them, the This is the storage bandwidth limit label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. l represents the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The bandwidth limit is defined in the request tag of the i-th storage request, and t is the time when the storage request was obtained. The request weight label is calculated using the following formula. Among them, the Let w be the request weight label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. i t represents the weight parameter in the request tag of the i-th storage request, and t represents the time when the storage request was obtained.

11. The method according to claim 10, characterized in that, The step of responding to each storage request based on the priority indicated by the request tags of each currently acquired storage request includes: Determine whether there is a first storage request among the various storage requests whose corresponding storage bandwidth lower limit label is greater than the current time; In the event of the first storage request, the response interface of the storage medium is activated so that the response interface responds to the first storage request; If the first storage request does not exist, or if the first storage request has been processed, determine the second storage request whose corresponding storage bandwidth limit label is not greater than the current time from the remaining storage requests; The second storage request is processed according to the priority order indicated by the request weight tag corresponding to the second storage request.

12. The method according to claim 11, characterized in that, The step of waking up the response interface of the storage medium in the presence of the first storage request, so that the response interface responds to the first storage request, includes: The processing order of the first storage request is determined according to the storage bandwidth lower limit label in ascending order; The response interface of the storage medium is awakened so that the response interface responds to the corresponding first storage request based on the processing order.

13. The method according to claim 10, characterized in that, Prior to the step of determining the request tag of the storage request, the method further includes: Based on the business type corresponding to the currently obtained storage request and the business type corresponding to the historical storage request, the request weight label corresponding to the historical storage request is adjusted according to the weight setting rules.

14. A data storage device, characterized in that, An in-vehicle storage terminal is used to store written audio and video streams and imported audio and video files. The audio and video streams are audio and video data acquired by an image acquisition device, and the audio and video files are imported from other storage media inside the in-vehicle storage terminal or from storage media outside the in-vehicle storage terminal. The device includes: The coefficient determination module is used to respond to an audio / video stream write request by determining the current buffer margin coefficient of the data buffer based on the dwell time of the currently written data frame in the data buffer, the positional relationship between the current write pointer position and the current used frame start position. The data buffer is used to cache audio / video data acquired from the image acquisition device. The current used frame start position is the position of the written data frame in the data buffer. The current buffer margin coefficient is used to characterize the size of the remaining space between the current used frame start position and the position covered by the write pointer position. The write parameter adjustment module is used to adjust the write parameters for writing data from the data cache to the storage medium according to the size of the remaining space represented by the current cache balance coefficient. The data storage module is used to retrieve audio and video data from the data buffer according to the adjusted write parameters and write it to the storage medium.

15. The apparatus according to claim 14, characterized in that, The coefficient determination module includes: The dwell time determination submodule is used to determine the time difference between the current time and the time when the write data frame currently written to the storage medium arrives at the data buffer, and use this as the dwell time of the write data frame in the data buffer; The coefficient first determination submodule is used to determine that the current cache balance coefficient is 0 when the dwell time is greater than the data storage time corresponding to the data cache area, wherein the data storage time is the first ratio of the total length of the data cache area to the write code rate of the data cache area; The second coefficient determination submodule is used to determine the current buffer capacity coefficient based on the positional relationship between the current write pointer position and the current used frame start position, provided that the dwell time is not greater than the data storage time corresponding to the data buffer; and / or, The second coefficient determination submodule includes: A storage space determination unit is used to determine the size of the storage space between the current write pointer position and the current used frame start position; The coefficient determination unit is used to take the second ratio of the storage space size to the total length of the data cache area as the current cache slack coefficient; and / or, The storage space determination unit is specifically used for: If the current write pointer position is before or the same as the current used frame start position, a first difference between the current write pointer position and the current used frame start position is calculated as the storage space size; if the current write pointer position is after the current used frame start position, the difference between a second difference between the current write pointer position and the current used frame start position and the total length of the data buffer is calculated as the storage space size; and / or, The write parameter adjustment module includes: The target bitrate determination submodule is used to determine the target bitrate for writing data from the data cache to the storage medium based on the change of the current cache balance coefficient compared with the historical cache balance coefficient, the size of the data cache area, and the bitrate of writing data from the data cache area to the storage medium, wherein the historical cache balance coefficient is the cache balance coefficient corresponding to the historical time before the current time. The target frame rate determination submodule is used to determine the target frame rate for writing data from the data buffer to the storage medium based on the change of the current buffer margin coefficient compared with the historical buffer margin coefficient and the frame rate of writing data from the data buffer to the storage medium when the target bit rate is the same as the preset minimum bit rate. A data writing submodule is used to write audio and video data from the data buffer to the storage medium according to the target bitrate and the target frame rate; and / or, The target bit rate determination submodule includes: The change determination unit is used to calculate the change in bit rate per unit time based on the change in the current cache availability coefficient compared to the historical cache availability coefficient. The first target bitrate determination unit is configured to determine the maximum bitrate as the target bitrate for writing data from the data buffer to the storage medium when the bitrate change per unit time is greater than 0 and the historical bitrate is a preset maximum bitrate, wherein the historical bitrate is the write bitrate for writing data from the data buffer to the storage medium at the historical moment. The second target bitrate determination unit is used to determine the minimum bitrate as the target bitrate for writing data from the data buffer to the storage medium when the bitrate change per unit time is less than 0 and the historical bitrate is not greater than the minimum bitrate. The third target bitrate determination unit is configured to, when the first sum of the bitrate change per unit time and the historical bitrate is not less than the minimum bitrate and not greater than the maximum bitrate, determine the second sum of the historical bitrate and the bitrate change per unit time as the target bitrate for writing data from the data buffer to the storage medium; and / or, The target frame rate determination submodule includes: The first target frame rate determining unit is configured to determine the maximum frame rate as the target frame rate for writing data from the data buffer to the storage medium when the bit rate change per unit time is greater than 0 and the historical frame rate is the maximum frame rate, wherein the historical frame rate is the write frame rate for writing data from the data buffer to the storage medium corresponding to the historical time. The second target frame rate determination unit is used to determine the minimum frame rate as the target frame rate for writing data from the data buffer to the storage medium when the bit rate change per unit time is less than 0 and the historical frame rate is the minimum frame rate. The target frame rate third determination unit is configured to, under other circumstances, calculate a first product of the maximum frame rate and the unit time bitrate change, a third ratio of the first product to the minimum bitrate, and determine the third ratio and the third sum of the historical frame rates as the target frame rate for writing data from the data buffer to the storage medium; and / or, The change determination unit is specifically used for: Calculate the first difference between the current cache balance coefficient and the historical cache balance coefficient, and the fourth ratio between the second difference between the current time and the historical time; Calculate the second product of the fourth ratio and the total size of the data buffer as the bitrate change per unit time; and / or, The device further includes: The request tag determination module is used to determine the request tag of the storage request when a storage request is obtained, wherein the storage request is an audio / video stream writing request or an audio / video file import request, and the request tag is used to characterize the priority corresponding to the storage request. The priority is determined based on the weight of the service type of the audio / video data indicated by the storage request and the preset bandwidth occupied by the service type. The request-response module is configured to respond to each storage request based on the priority indicated by the request tags of each of the currently acquired storage requests; and / or, The request label includes a storage bandwidth lower limit label, a storage bandwidth upper limit label, and a request weight label. The request label determination module includes: The first calculation submodule is used to calculate the storage bandwidth lower limit label according to the following formula. Among them, the This is the lower limit label for the storage bandwidth of the (r-1)th storage request for the i-th audio / video stream or audio / video file. Let r be the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The reserved bandwidth in the request tag of the i-th storage request, and t is the time when the storage request is obtained; The second calculation submodule is used to calculate the storage bandwidth upper limit label according to the following formula. Among them, the This is the storage bandwidth limit label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. l represents the amount of data corresponding to the r-th storage request of the i-th audio / video stream or audio / video file. i The bandwidth limit is defined in the request tag of the i-th storage request, and t is the time when the storage request was obtained. The third calculation submodule is used to calculate the request weight label according to the following formula. Among them, the Let w be the request weight label for the (r-1)th storage request of the i-th audio / video stream or audio / video file. i The weight parameter in the request tag of the i-th storage request is t, where t is the time when the storage request was obtained; and / or, The request-response module includes: The first storage request determination submodule is used to determine whether there is a first storage request among the various storage requests whose corresponding storage bandwidth lower limit label is greater than the current time. The request response first submodule is used to wake up the response interface of the storage medium when the first storage request exists, so that the response interface responds to the first storage request; The second storage request determination submodule is used to determine, from the remaining storage requests, a second storage request whose corresponding storage bandwidth upper limit label is not greater than the current time, in the case where there is no first storage request or the first storage request has been processed. The second storage request processing submodule is configured to process the second storage request according to the priority order indicated by the request weight tag corresponding to the second storage request; and / or, The first submodule of the request response includes: The sequence determination unit is used to determine the processing order of the first storage request according to the storage bandwidth lower limit label in ascending order; A request-response unit is configured to wake up the response interface of the storage medium, so that the response interface responds to the corresponding first storage request based on the processing order; and / or, The device further includes: The request weight label adjustment module is used to adjust the request weight label corresponding to the historical storage request based on the business type corresponding to the currently obtained storage request and the business type corresponding to the historical storage request, according to the weight setting rules.

16. A vehicle-mounted storage terminal, characterized in that, The method includes a processor and a machine-readable storage medium storing machine-executable instructions that can be executed by the processor, which in turn cause the processor to perform the method of any one of claims 1-13.

17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-13.