CN105306949B - Video encoding method and apparatus - Google Patents

Video encoding method and apparatus Download PDF

Info

Publication number
CN105306949B
CN105306949B CN201510883867.0A CN201510883867A CN105306949B CN 105306949 B CN105306949 B CN 105306949B CN 201510883867 A CN201510883867 A CN 201510883867A CN 105306949 B CN105306949 B CN 105306949B
Authority
CN
China
Prior art keywords
coding
encoding
application layer
thread
channels
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510883867.0A
Other languages
Chinese (zh)
Other versions
CN105306949A (en
Inventor
王大治
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongxing Technology Co Ltd
Original Assignee
Mid Star Technology Ltd By Share Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mid Star Technology Ltd By Share Ltd filed Critical Mid Star Technology Ltd By Share Ltd
Priority to CN201510883867.0A priority Critical patent/CN105306949B/en
Publication of CN105306949A publication Critical patent/CN105306949A/en
Application granted granted Critical
Publication of CN105306949B publication Critical patent/CN105306949B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses a video coding method and a video coding device, which support simultaneous coding of a plurality of application layer coding threads by utilizing a plurality of coding channels of a hardware coding device. The method comprises the following steps: binding at least one application layer encoding thread of the plurality of application layer encoding threads with one encoding channel of the plurality of encoding channels; activating the bound encoding channels to encode the video; and awakening at least one application layer coding thread bound with one coding channel after the coding of the coding channel is finished. According to the embodiment of the invention, the application thread corresponding to the code can be accurately awakened after the coding channel finishes coding, and other threads are not affected.

Description

Video encoding method and apparatus
Technical Field
Embodiments of the present invention relate to video encoding and, in particular, to application layer encoding thread wakeup in video encoding that supports multiple encoding channels.
Background
At present, a hardware coding device can support a plurality of independent coding channels, so that multi-channel parallel coding is realized, and the requirement that different application layer coding threads need to carry out video coding at the same time is met.
When the data coding on one coding channel is completed, the coding channel generates an interrupt notification to notify a driving module of the coding channel, and the driving module needs to wake up an application layer coding thread to read a code stream of the coding channel. Currently, for multi-path coding, a mode of querying after thread awakening is mostly adopted. When the encoding is successful once, all the application layer encoding threads are awakened, then the encoding channels allocated to the application layer encoding threads are known not to be encoded by inquiry, and then the application layer encoding threads enter the sleep waiting mode again. This wastes the system on much wasted work, which reduces the system efficiency.
For example, fig. 1 shows a schematic diagram of waking up an application layer encoding thread after one encoding channel encoding is completed according to the prior art. The hardware encoding device 120 may support multiple encoding channels 122-1, 122-2, … … 122-n. The driver module 124 of the hardware encoding device 120 assigns encoding channels 1122-1 for the encoding thread 1112 of the application layer 110 and encoding channels 2122-2 for the encoding thread 2114 of the application layer 110, and maintains such an assignment. As shown in FIG. 1, if the data encoding is completed in encoding channel 1, then encoding channel 1 will generate an interrupt to notify the driver module 124, as indicated by arrow 130, and the driver module 124 will wake up all the application layer encoding threads, i.e., 112 and 114, as indicated by arrows 132 and 134. Thereafter, both application-layer encoding threads 112 and 114 will query the driver module 124 for the presence of encoded data for the encoding pass assigned to itself. As shown in fig. 1, after being woken up, the encoding thread 2114 finds, through query, that there is no available encoding code stream on the encoding channel allocated to itself, and enters the sleep waiting state again. This waking up and sleeping again of the encoding thread 2114 is a waste of system resources.
For example, in the case that the driver module of the hardware coding device 120 is developed by using a Linux system, for multi-path coding, a select function is mostly used for querying, and after the function is woken back, a system call is used for querying whether encoded data is generated in the path, if so, the data is read out for processing, and if not, the sleep is continued for waiting. The processing in the driver program is that after one path of codes is generated, all threads waiting on the device are awakened through a poll function, for all n paths of codes, only one path of codes can really acquire data, other n-1 paths of codes are awakened, and the driver program sleeps again after inquiring that no data exists. Thus, the other n-1 ways are inefficiently and meaninglessly awakened and queried, burdening the system without actual efficiency.
Disclosure of Invention
Accordingly, the present invention is directed to solving one or more of the problems set forth above and to providing an innovative application-layer encoding thread wakeup in video encoding that supports multiple encoding channels.
According to one aspect of the present invention, a video encoding method is provided that supports simultaneous encoding of multiple application layer encoding threads using multiple encoding channels of a hardware encoding device. The method comprises the following steps: binding at least one of the plurality of application layer encoding threads with one of the plurality of encoding channels; activating the bound encoding pass of the plurality of encoding passes to encode video; and awakening at least one application layer coding thread bound with one of the plurality of coding channels after the coding of the one of the plurality of coding channels is finished.
According to one aspect of the present invention, there is provided a video encoding apparatus that supports simultaneous encoding of multiple application layer encoding threads using multiple encoding channels of a hardware encoding device. The video encoding device includes: a binding module for binding at least one of the plurality of application layer encoding threads with one of the plurality of encoding channels; an encoding module for activating the bound encoding channel of the plurality of encoding channels for encoding video; and the awakening module is used for awakening at least one application layer coding thread bound with one coding channel in the plurality of coding channels after the coding of the coding channel is finished.
According to the embodiment of the invention, after the coding channel of the hardware coding device completes coding, the application layer coding thread corresponding to the coding can be accurately awakened without influencing other threads.
Drawings
Features, advantages and other aspects of various embodiments of the present invention will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. In the drawings:
FIG. 1 shows a schematic diagram of waking up an application layer encoding thread according to the prior art;
FIG. 2 shows a schematic diagram of waking up an application layer encoding thread according to an embodiment of the invention;
fig. 3 illustrates a flow chart of a video encoding method according to an embodiment of the present invention; and
fig. 4 illustrates a block diagram of a video encoding apparatus according to an embodiment of the present invention.
Detailed Description
The principles and spirit of the present invention will be described with reference to a number of exemplary embodiments in conjunction with the following drawings. It is understood that these embodiments are given solely for the purpose of enabling those skilled in the art to better understand and to practice the invention, and are not intended to limit the scope of the invention in any way.
Fig. 2 is a schematic diagram illustrating that an application layer encoding thread is woken up after one encoding channel is encoded according to an embodiment of the present invention. Unlike the prior art processing method shown in fig. 1, the embodiment of the present invention establishes the binding relationship between the application layer coding thread and the hardware coding channel when opening a coding channel for an application layer coding thread. Therefore, after the hardware coding device completes the coding of a frame of code stream, the driver can accurately wake up the thread waiting on the path according to the binding relation, so that the coding thread can acquire the coded code stream.
As shown in fig. 2, the driver module 124 may, for example, upon receiving an encoding request of an application layer encoding thread 1112, assign and open an encoding channel 1122-1 for the encoding thread and record a binding relationship with the application layer encoding thread 1112. If the encoding of data is completed in encoding channel 1, then encoding channel 1 will generate an interrupt to notify the driving module 124, as indicated by arrow 130. The driver module 124, knowing the binding of code channel 1 to the application layer code thread 1112, only wakes up the application layer code thread 1112 and does not wake up the application layer code thread 2114. In contrast to the prior art wake-up scheme of fig. 1, it is also possible to omit the query process of the application layer encoding threads 1 and 2 to the driver module 124.
Fig. 3 shows a flow diagram of a video encoding method 300 according to an embodiment of the invention. The method starts in step S300.
Step S310, binding an application layer encoding thread of the plurality of application layer encoding threads with an encoding channel of the plurality of encoding channels. Usually, the maximum number of encoding paths that can be supported by a hardware encoding device is fixed, for example, if 16 encoding paths are simultaneously supported, there are 16 encoding paths, and one path can support one application thread to acquire a code stream. The binding relationship between the application layer coding thread and the coding channel can be established when the drive module opens one coding channel in the hardware coding device for one application layer coding thread.
Step S320, activating the bound encoding channel of the plurality of encoding channels so as to encode the video.
Step S330, after one of the multiple encoding channels finishes encoding, according to the binding, waking up the application layer encoding thread bound with the one of the multiple encoding channels.
To this end, the method 300 ends at step S340.
In one embodiment, an encoding pass is bound to only one application layer encoding thread, and after the encoding pass completes encoding, the encoding pass is unbound from the application layer encoding thread. This is particularly suitable where the number of application layer encoding threads expected to encode simultaneously is less than the number of encoding channels that the hardware encoding device can support.
In one embodiment, an encoding thread queue may be established for an encoding channel that is bound to a plurality of application layer encoding threads that make up the encoding thread queue. This is particularly suitable for situations where the number of surviving application layer coding threads is greater than the number of coding channels that the hardware coding device can support. In this case, all application layer encoding threads in the encoding thread queue for one encoding channel may be woken up after encoding on the encoding channel is completed.
The coding thread queue may adopt a first-in first-out queue, and in the code stream of the coding channel read by the application layer coding thread at the head of the queue, the application layer coding thread may be deleted from the coding thread queue.
An example of a driver module developed using the Linux system according to an embodiment of the present invention is described below. However, it should be understood that embodiments of the present invention may also be applied to driver modules of hardware coding devices developed using other operating systems or programming environments.
The drive of the hardware coding device works in a Linux kernel (kernel) part. The hardware coding device bottom layer can provide multiple paths of simultaneous coding, for example, 16 paths of code streams with different resolutions. The encoding thread is a program working in an application layer, and corresponding to 16 paths of encoding of hardware, 16 application threads can run simultaneously to obtain 16 paths of code streams with different resolutions. For example, a user a starts an application, and needs to encode a code stream of 640 × 480, which is an encoding thread; user B starts an application, and needs to encode a 720 × 576 code stream, which is also an encoding thread. The two threads appear to be acquiring codestreams simultaneously, and they work at the application layer, so they are called encoding threads of the application layer. And the two paths of codes are all completed by a code driving module at the bottom layer through one piece of hardware.
When the user A starts the application to start coding, the coding thread of the user A needs to call a bottom hardware coding device, and a coded code stream is obtained from the bottom hardware coding device. The encoding thread of the user A acquires a handle distributed by a drive module of the hardware encoding device through a system call function Open (), the handle is used for interaction information between the encoding thread and the drive module, and then the encoding thread of the user A calls a select function of the encoding thread to wait. For example, the driver module assigns handle a to user A's encoding thread and assigns encoding channel 1 of the 16-way encoding channel to it. Thus, the binding of handle a and code channel 1 is established in the driver module. In other words, for the driver module, the handle a represents the application layer encoding thread of the user a, and the encoding channel 1 of the hardware encoding device is the channel to which the handle a is bound. Likewise, the handle B and the encoding channel 2 allocated by the encoding thread of the user B may also be bound.
After binding, the data of all code channels 1 are only related to the handle a, and the data of all code channels 2 are only related to the handle b.
After the data on one coding channel is compressed, the driving module can judge that the data is the data of the physical channel according to the coded interrupt signal sent by the coding channel. For example, if the data of the encoding channel 1 is determined to be compressed, the data of the handle a can be known through binding, and the driver module will only wake up the select function corresponding to the handle a. Thus, only user A's encoding thread will be woken up to retrieve data, while other users' application layer encoding threads are not woken up.
When the application layer encoding thread of the user a is awakened because the select function thereof is called, the application layer encoding thread can inquire the completion status of the encoding channel allocated to the user a from the driving module, and call the system function Read () to Read the data on the allocated encoding channel.
In the above embodiments of the application layer encoding threads of user a and user B, one encoding channel supported by the hardware encoding device is allocated to only one application layer encoding thread. Alternatively, for example, after the application layer encoding thread of the user a is woken up, the system function Read () may also be directly called to Read the code stream on the allocated encoding channel.
In another embodiment, one encoding channel may also be allocated for multiple application layer encoding threads. In this way, an application layer encoding thread queue may be established for the encoding channel to which it is bound. And awakening all application layer coding threads bound with the coding channel each time the coding channel finishes coding. Each awakened application layer coding thread can query the driving module to acquire the position of the handle distributed to the driving module in the queue so as to acquire whether the finished coding code stream is specific to the driving module. If so, the system function Read () may be called to Read the codestream on the encoding channel and the handle a of the application thread is removed from the queue.
Referring now to fig. 4, a video encoding apparatus 400 capable of supporting simultaneous encoding of multiple application layer encoding threads using multiple encoding channels of a hardware encoding device in accordance with one embodiment of the present invention is schematically illustrated. The apparatus 400 comprises: a binding module 410 for binding at least one of the plurality of application layer coding threads with one of the plurality of coding channels; an encoding module 420 for activating the bound encoding channel of the plurality of encoding channels for encoding video; and a wake-up module 430, configured to wake up at least one application layer encoding thread bound to one of the multiple encoding channels after the encoding of the one of the multiple encoding channels is completed.
In one embodiment, the apparatus 400 may further include a unbinding module configured to unbind one of the plurality of application layer encoding threads after the one of the plurality of encoding passes completes encoding.
In one embodiment, the apparatus 400 may further include an encoding thread queue establishing module for establishing an encoding thread queue for each encoding channel of the plurality of encoding channels. The wake-up module 420 may further include: and the coding thread queue awakening module is used for awakening all application layer coding threads of the coding thread queue bound with the coding channel in the plurality of coding channels.
The apparatus 400 may further comprise: the reading module is used for enabling an application layer coding thread bound with one coding channel in the plurality of coding channels which completes coding and located at the head of the coding thread queue to read a code stream in the coding channel which completes coding; and the deleting module is used for deleting the application layer coding thread positioned at the head of the coding thread queue from the application layer coding thread.
It should be understood that each unit recited in the apparatus 400 corresponds to each step in the method 300 described with reference to fig. 3. Thus, the operations and features described above with respect to fig. 3 are equally applicable to the apparatus 40 and the units contained therein and will not be described again here.
It should also be understood that the apparatus 400 may be implemented in a variety of ways, for example, in some embodiments, the apparatus 400 may be implemented using software and/or firmware modules. Furthermore, the apparatus 400 may also be implemented using hardware modules. Other ways, now known or later developed, are also feasible, and the scope of the present invention is not limited in this respect.
Those skilled in the art will appreciate that the flow charts and block diagrams in the figures are merely schematic representations of the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
According to the embodiment of the invention, after a hardware coding device codes a frame of code stream, a driving module of the hardware coding device can accurately wake up an application layer coding thread waiting on the path, so that the thread can acquire the coded code stream without influencing other coding paths.
The description of the present invention has been presented for purposes of illustration and description, but is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will occur to those skilled in the art. All changes and substitutions that may be made without departing from the spirit of the invention are intended to be within the scope of the invention as defined by the appended claims.

Claims (8)

1. A video encoding method that supports simultaneous encoding of multiple application layer encoding threads using multiple encoding channels of a hardware encoding device, the method comprising:
binding at least one application layer coding thread in the plurality of application layer coding threads with one coding channel in the plurality of coding channels to obtain a binding relationship;
activating the bound encoding pass of the plurality of encoding passes to encode video; and
after one coding channel in the multiple coding channels finishes coding, awakening at least one application layer coding thread bound with the one coding channel in the multiple coding channels according to the binding relationship;
wherein establishing a coding thread queue for each of the plurality of coding channels, wherein the waking up at least one application layer coding thread bound to the one of the plurality of coding channels comprises:
waking up all application layer encoding threads of an encoding thread queue bound to the one of the plurality of encoding channels.
2. The video coding method of claim 1, further comprising:
and after one of the plurality of coding channels finishes coding, releasing the binding of the coding channel and one of the plurality of application layer coding threads.
3. The video coding method of claim 1, further comprising:
enabling an application layer coding thread bound with one coding channel in the plurality of coding channels with the coding completed and positioned at the head of the coding thread queue to read a code stream in the coding channel with the coding completed; and
and deleting the application layer coding thread at the head of the coding thread queue from the application layer coding thread.
4. The video encoding method of any of claims 1-3, wherein the waking up at least one application layer encoding thread bound to the one of the plurality of encoding channels comprises:
waking a select function of the at least one application layer encoding thread.
5. An apparatus for video encoding that supports simultaneous encoding of multiple application layer encoding threads using multiple encoding channels of a hardware encoding device, the apparatus comprising:
the binding module is used for binding at least one application layer coding thread in the plurality of application layer coding threads with one coding channel in the plurality of coding channels to obtain a binding relationship;
an encoding module for activating the bound encoding channel of the plurality of encoding channels for encoding video; and
the awakening module is used for awakening at least one application layer coding thread bound with one coding channel in the coding channels according to the binding relationship after the coding of the coding channel in the coding channels is finished;
an encoding thread queue establishing module, configured to establish an encoding thread queue for each of the plurality of encoding channels, wherein the wake-up module further includes:
and the coding thread queue awakening module is used for awakening all application layer coding threads of the coding thread queue bound with the coding channel in the plurality of coding channels.
6. The video coding device of claim 5, further comprising:
and the releasing module is used for releasing the binding of one of the application layer coding threads and one of the application layer coding threads after one of the coding channels completes coding.
7. The video coding device of claim 5, further comprising:
the reading module is used for enabling an application layer coding thread bound with one coding channel in the plurality of coding channels which completes coding and located at the head of the coding thread queue to read a code stream in the coding channel which completes coding; and
and the deleting module is used for deleting the application layer coding thread positioned at the head of the coding thread queue from the application layer coding thread.
8. The video encoding apparatus of any of claims 5-7, wherein the waking up at least one application layer encoding thread bound to the one of the plurality of encoding channels comprises:
waking a select function of the at least one application layer encoding thread.
CN201510883867.0A 2015-12-04 2015-12-04 Video encoding method and apparatus Active CN105306949B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510883867.0A CN105306949B (en) 2015-12-04 2015-12-04 Video encoding method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510883867.0A CN105306949B (en) 2015-12-04 2015-12-04 Video encoding method and apparatus

Publications (2)

Publication Number Publication Date
CN105306949A CN105306949A (en) 2016-02-03
CN105306949B true CN105306949B (en) 2020-05-26

Family

ID=55203624

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510883867.0A Active CN105306949B (en) 2015-12-04 2015-12-04 Video encoding method and apparatus

Country Status (1)

Country Link
CN (1) CN105306949B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102801969A (en) * 2012-07-25 2012-11-28 华为技术有限公司 Method, device and system of processing multimedia data
CN103955408A (en) * 2014-04-24 2014-07-30 深圳中微电科技有限公司 Thread management method and device with DMA (direct memory access) participation in MVP (multi thread virtual pipeline) processor

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1298157C (en) * 2004-11-30 2007-01-31 北京中星微电子有限公司 Audio and visual frequencies synchronizing method for IP network conference
CN101198049B (en) * 2007-12-29 2010-06-09 北京中企开源信息技术有限公司 Video data processing method and device
CN102217308B (en) * 2008-11-13 2014-10-22 汤姆森特许公司 Multiple thread video encoding using gop merging and bit allocation
CN102724561A (en) * 2012-05-16 2012-10-10 昆山日通电脑科技办公设备有限公司 Embedded real time streaming media network transmission method and implementation system thereof

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102801969A (en) * 2012-07-25 2012-11-28 华为技术有限公司 Method, device and system of processing multimedia data
CN103955408A (en) * 2014-04-24 2014-07-30 深圳中微电科技有限公司 Thread management method and device with DMA (direct memory access) participation in MVP (multi thread virtual pipeline) processor

Also Published As

Publication number Publication date
CN105306949A (en) 2016-02-03

Similar Documents

Publication Publication Date Title
US20200358979A1 (en) System and method for supporting selective backtracking data recording
CN110769278B (en) Distributed video transcoding method and system
JP2003298661A (en) Stream data processing equipment, method therefor, program and medium
CN110602122A (en) Video processing method and device, electronic equipment and storage medium
CN104185062A (en) Method for processing video streams by terminal and terminal
CN105630588A (en) Distributed job scheduling method and system
JPWO2009153977A1 (en) Multiprocessor
KR20210150611A (en) Memory access technology and computer system
JP2009237888A (en) Data processor, image coding/decoding device, and data processing system
EP1747513A1 (en) Hierarchical processor architecture for video processing
CN102117308A (en) Data processing method and data processing system
KR20100042629A (en) Method and apparatus for encoding and decoding multimedia data
CN105306949B (en) Video encoding method and apparatus
CN107566543B (en) Node identifier setting method and device
CN102447965B (en) Method and device supporting access of video plug-in for quickly and smoothly displaying video
CN112035066A (en) Method and device for calculating log retention time
US11736700B2 (en) Multi-threading in a video hardware engine
CN111158885B (en) Concurrency control method and device in job scheduling system
CN101090470B (en) Information processing apparatus and information processing method
WO2006070299A1 (en) Method and apparatus for synchronization control of digital signals
CN113824955B (en) Multi-channel video time-sharing multiplexing coding method and system
CN102868881A (en) Video encoding system and method
CN106375777B (en) A kind of audio-video recording method and system
CN109784112B (en) Automobile electronic identification reading and writing method and device, electronic equipment and medium
CN114268793B (en) Coding method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20171211

Address after: 519000 Guangdong city of Zhuhai province Hengqin Baohua Road No. 6, room 105, -23898 (central office)

Applicant after: Zhongxing Technology Co., Ltd.

Address before: 100083 Haidian District, Xueyuan Road, No. 35, the world building, the second floor of the building on the ground floor, No. 16

Applicant before: Beijing Vimicro Corporation

TA01 Transfer of patent application right
CB02 Change of applicant information

Address after: 519031 Guangdong city of Zhuhai province Hengqin Baohua Road No. 6, room 105, -23898 (central office)

Applicant after: Mid Star Technology Limited by Share Ltd

Address before: 519000 Guangdong city of Zhuhai province Hengqin Baohua Road No. 6, room 105, -23898 (central office)

Applicant before: Zhongxing Technology Co., Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant